canot find class name? whats wrong?

//=======================================================

// Changes the name on the account

//=======================================================

publicvoid name(String newName)

{

name = newName;

}

public String getName()

{

return name;

}

publicvoid writeOutput()

{

System.out.println("Name: " + name);

}

the above is part of my class and my objective is to change a name, but i get an error, any advice?

//change the name on Joe's account to Joseph

acct2=new name("Joseph");

[1163 byte] By [MEGSPAULa] at [2007-10-3 8:25:57]
# 1
Show more code and paste the exact error message.
jverda at 2007-7-15 3:32:16 > top of Java-index,Java Essentials,Java Programming...
# 2

Here is the class.

//========================================================

//Account.java

//

// A bank account class with methods to deposit to, withdraw from,

// change the name on, charge a fee to, and print a summary

// of account.

//=======================================================

import java.text.NumberFormat;

public class Account

{

private double balance;

private String name;

private long acctNum;

private final double fee=15.00;

//=======================================================

//Constructor -- initializes balance, owner, & account#

//=======================================================

public Account(double initBal, String owner, long number)

{

balance=initBal;

name=owner;

acctNum=number;

}

//=======================================================

// Checks to see if balance is suffiecient for withdrawal.

// If so, decrements balance by amount; if not, prints

// message.

//=======================================================

public void withdraw(double amount)

{

if (balance >=amount)

balance-=amount;

else

System.out.println("Insufficient funds");

}

//========================================================

// Adds deposit amount to balance.

//========================================================

public void deposit(double amount)

{

balance+=amount;

}

//========================================================

// Returns balance.

//========================================================

public double getBalance()

{

return balance;

}

//============================================================

// Returns a string containing the name, account# and balance

//============================================================

public String toString()

{

NumberFormat fmt=NumberFormat.getCurrencyInstance();

return(acctNum + "\t" + name + "\t" + fmt.format(balance));

}

//=======================================================

// Deducts $10 service fee

//=======================================================

public void chargeFee()

{

balance=balance-fee;

}

//=======================================================

// Changes the name on the account

//=======================================================

public void name(String newName)

{

name = newName;

}

public String getName()

{

return name;

}

}

//===============================================================

// ManageAccounts.java

//

// Use Account Class to create and manage Sally and Joe's

// bank accounts

//==============================================================

public class ManageAccounts

{

public static void main(String[]args)

{

Account acct1, acct2;

//create account 1 for Sally with $1000

acct1= new Account(1000, "Sally", 1111);

//creat account 2 for Joe with $500

acct2= new Account(500, "Joe", 2222);

//deposit $100 to Joe's account

acct2.deposit(100);

//print Joe's new balance (use getBalance())

System.out.println("Joe's balance is: " + acct2.getBalance());

//withdraw $50 from Sally's account

acct1.withdraw(50);

//print Sally's new balance (use getBalance())

System.out.println("Sally's balance is: " + acct1.getBalance());

//charge fees to both accounts

acct1.chargeFee();

acct2.chargeFee();

//change the name on Joe's account to Joseph

acct2= new name("Joseph");

//print summary for both accounts

System.out.println(acct1);

System.out.println(acct2);

}

}

error isline 39 in second part [cannot find symbol class name]

MEGSPAULa at 2007-7-15 3:32:16 > top of Java-index,Java Essentials,Java Programming...
# 3

This code is trying to assing the var acct2 to a new object of type name, with an argument of "Joseph"

//change the name on Joe's account to Joseph

acct2= new name("Joseph");

what you really want to do is change the name property of the account to "Joseph", like this.

acct2.name("Joseph");

on another front, accessors and mutators (getters and setters) should be written like so:

//the property / member variable

private String name;

//the getter

public String getName()

{

return name;

}

//the setter

public void setName(String newName)

{

this.name = newName;

}

Message was edited by:

SomeoneElse

SomeoneElsea at 2007-7-15 3:32:16 > top of Java-index,Java Essentials,Java Programming...
# 4
i still get the same error
MEGSPAULa at 2007-7-15 3:32:16 > top of Java-index,Java Essentials,Java Programming...
# 5
i used setName which compiled ok. . thanks :)
MEGSPAULa at 2007-7-15 3:32:16 > top of Java-index,Java Essentials,Java Programming...