0

So I've recently been learning java and have been using www.javacoffeebreak.com for my first tutorial, anyway everything's been going smoothly til I get to here: http://javacoffeebreak.com/java102/java102.html

The code that's giving me that error is the following:

public class Account 
{
        protected double balance;

        // Constructor to initialize balance
        public Account( double amount )
	{
		balance = amount;
	}

        // Overloaded constructor for empty balance
        public Account()
	{
		balance = 0.0;
	}

        public void deposit( double amount )
	{
		balance += amount;
	}

        public double withdraw( double amount )
	{
                // See if amount can be withdrawn
		if (balance >= amount)
		{
			balance -= amount;
                        return amount;
		}
		else
                // Withdrawal not allowed
                        return 0.0;
	}

        public double getbalance()
	{
                return balance;
	}
}

Anyone see what I'm doing wrong? Thanks in advance.

Edited by Corrderio: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Corrderio
0

Yes, you are supposed to follow the tutorial till the end and execute AccountDemo.java and not just Account.java.
Account class is just sort of storage design to hold data associated with accounting. This class normally provide some constructors to create object in the memory, some setter and getters to provide wait to manipulate variables used by the object, and more often some methods that are associated in some way with account object like in this case make deposit, withdraw and get balance.

0

Ahh I see, thanks. I'm usually use to tutorials giving out very simple code like I posted above, then afterwards having you expand on the code if it works.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.