Hallo ,
this is a class in bluej about car details i created
the problems so far in the class are that it allows any number in the transmition when i go to create the class , it should only allow 1 and 2(i dont really need to do it , but i am asking if there is a way around it ) and also in the toString method to show the manual and automatic and not 1 and 2 in the type
thanks for all the help
public class Car { // set up the two constants for the transmition public static final int manual = 1; public static final int automatic = 2; // instance variables - replace the example below with your own private static int engineSize; private int fuel; private final int type ; /** * Constructor for objects of class Car */ public Car(int newFuel , int newEngineSize , int Trans ) { fuel = newFuel; engineSize = newEngineSize; type = Trans; } /** Change the fuel */ public void getFuel() { System.out.println("The fuel of this car is " + fuel ); } public void getEngineSize() { System.out.println("The engineSize of this car is " + engineSize); } public void setFuel( int newfuel) { fuel = newfuel; } public String getTypeAsString (){ if (type == automatic){ return "automatic"; } else if (type == manual){ return "manual"; } return ""; } public String toString(){ return ("fuel " + fuel + " Engine Size " + engineSize + " Transmition " + type ) ; } }