I need to change a value in mustang, and I have a couple of questions. Mustang is set to the default constructor, and I need to change all of the values. (color, model, horsePower, and doors) Can I consolidate the four change(variable)'s into one statement? Like this:
Mustang declare:
How I would I change a value using change(variable) in the main driver, I tried looking everywhere.
public void changeAll(int h, String c, String m, int d) {
horsePower = h;
color = c;
model = m;
doors = d;
}
Mustang declare:
autoB mustang = new autoB();Stand Alone Class:
package auto;
public class autoB {
private int horsePower;
private int doors;
private String model;
private String color;
public autoB() {
horsePower = 250;
color = "red";
model = "charger";
doors = 4;
}
public autoB(int h, String c, String m, int d) {
horsePower = h;
color = c;
model = m;
doors = d;
}
public int getHorse() {
return horsePower;
}
public int getDoors() {
return doors;
}
public String getColor() {
return color;
}
public String getModel() {
return model;
}
public void changeHorse(int h) {
horsePower = h;
}
public int changeDoors(int d) {
doors = d;
return doors;
}
public String changeColor(String c) {
color = c;
return color;
}
public String changeModel(String m) {
model = m;
return model;
}
public String toString() {
return "Horse Power: " + horsePower + " Color: " + color + " Model: " + model + " Doors: " + doors;
}
public boolean equals(Object obj) {
autoB a = (autoB) obj;
if (model.equalsIgnoreCase(a.getModel())) {
return true;
} else {
return false;
}
}
}
How I would I change a value using change(variable) in the main driver, I tried looking everywhere.