Image

Imagereuptake wrote in Imagejava_dev

I'm having problems understanding and starting a Java assignment I have to complete.

We need to Develop and implement a class Account that represents a savings account (no interest stuff, thank god). It has 3 attributes: the name of the account, the owner of the account, and the current balance.

It needs to have the following constructors behaviors:

Name(): to configure a new account w/ name "name", owner "owner", and balance 0.
Name(String s, Stirng t, double n): to configure a new account with name s, owner t, and balance n
void deposit (double n): adds amount to n to the current balance of the associated account
void withdraw (double n) ....... same thing, but subtracts
void close(): zeroes out the account balance, sets the owner to "".
String getAccountName(): returns the name of the associated account.
String getOwner(): returns the owner
double getBalance(): returns the balance
void setName(String s): sets the name to s
void setOwner(String s): sets the owner to s
String toString(): to return a textual representation of the attributes of the account.

I'm way confused. I thought constructors could only be the same as their class name. Is it saying that Name() is a constructor? I don't think we need to be using default constructors for this, but I'm not sure. I've been messing around with coding it for a while, and I just don't know what the heck I'm doing.


public class Account {


public Account(String s, String t, double n){
setName (s) ;
setOwner(t) ;
setBalance(n) ;
n = balance ;
t = owner;
s = name;

}


public void deposit(double n){
getBalance() = getBalance() + n;
}
public void withdraw(double n){
getBalance() = getBalance() - n ;
}
public void close(){
getBalance() = getBalance() - getBalance();
}
public String getAccountName() {
return s;
}
public String getOwner() {
return owner;
}
public double getBalance(){
return balance;
}
public void setName(String s){
name = s;
}

public void setOwner(String s){
owner = s;
}
public String toString () {
String s = getAccountName() ;
String t = getOwner();
double n = getBalance();
return s + "; " + t + "; " + n ;
}

}

What am I doing wrong?