Can someone see whats wrong with my code, please?
Here it is;
public class Car {
private String make;
private String model;
private int year;
public Car() {
this.make = "Nissan";
this.model = "Sivia";
this.year = 1992;
}
public Car( String make,
String model,
int year ) {
this.make = make;
this.model = model;
this.year = year;
}
public Car( String make ) {
this.make = "Toyota";
this.model = "Supra";
this.year = 1996;
}
public String getMake() {
return this.make;
}
public String getModel() {
return this.model;
}
public int getYear() {
}
public void setMake(String make) {
this.make = make;
}
public void setModel(String model) {
this.model = model;
}
public void setYear( int year ) {
this.year = year;
}
public String toString() {
String out = "This is a Car. ";
out += "Its make is " + this.make + ". ";
out += "Its model is " + this.model + ". ";
out += "Its year is " + this.year + ".";
return out;
}
public String carTester(String make) {
Car theCar = new Car(make);
this.make = Car;
this.model = Car;
this.year = Car;
return theCar.toString();
}
public static void main( String[] args) {
System.out.println(carTester);
}
I'd like it to print out the make model and year, ( 1992 nissan silvia )
PLEASE HELP ME!!!
Re: Can someone see whats wrong with my code, please?
Please see the link in my signature entitled 'getting help'.
Re: Can someone see whats wrong with my code, please?
Code :
public class Car
{
private String make;
private String model;
private int year;
public Car() {
this.make = "Nissan";
this.model = "Sivia";
this.year = 1992;
}
public Car( String make, String model, int year ) {
this.make = make;
this.model = model;
this.year = year;
}
public String getMake() {
return this.make;
}
public String getModel() {
return this.model;
}
public int getYear() {
return this.year;
}
public void setMake(String make) {
this.make = make;
}
public void setModel(String model) {
this.model = model;
}
public void setYear( int year ) {
this.year = year;
}
public String toString() {
String out = "This is a Car.\n";
out += "Its make is " + this.make + ".\n";
out += "Its model is " + this.model + ".\n";
out += "Its year is " + this.year + ".\n";
return out;
}
//dont understand this crap
//why are you even using this class
/*public String carTester(String make) {
Car theCar = new Car(make);
this.make = Car;
this.model = Car;
this.year = Car;
return theCar.toString();
}
*/
public static void main( String[] args) {
Car mycar = new Car();
System.out.println(mycar);
}
}