Getters, Setters , Object Java -
i'm not sure wrong code. code person
class shown below.
i have no idea start main method, object person class instantiated this:
newperson = new person( "richard pelletier", "1313 park blvd", "san diego, ca 92101", "(619) 388-3113" );
person:
public class person { private string name; private string address; private string citystatezip; private string phone; public person(){} public person( string name, string address, string phone ) { this.name = name; this.address = address; this.phone = phone; } public void setname( string name ) { this.name = name; } public void setaddress( string address ) { this.address = address; } public void setphone( string phone ) { this.phone = phone; } public string getname() { return name; } public string getadress() { return address; } public string getphone() { return phone; } public string tostring() { return ("" + this.name + "" + this.address + "" + this.phone); } }
i assume have compiler error. constructor accepts 3 string
arguments , trying pass four. try adding following constructor (or replace existing one):
public person( string name, string address, string citystatezip, string phone ) { this.name = name; this.address = address; this.citystatezip = citystatezip; this.phone = phone; }
Comments
Post a Comment