Question: // Could you make this code work? It is not printing out anything for me. import java.util.*; class Vehicle{ private String myBrand; private String myModel;

// Could you make this code work? It is not printing out anything for me. import java.util.*; class Vehicle{ private String myBrand; private String myModel; public Vehicle(String b, String m){ myBrand = b; myModel = m; } public String getBrand(){ return myBrand; } public String getModel(){ return myModel; } public String toString(){ return "The brand is " + myBrand + " and model is " + myModel; } } class Bicycle extends Vehicle{ private int myGearCount; public Bicycle(String b, String m, int gc){ super(b,m); if (gc >= 4) myGearCount = gc; else { System.out.println("Invalid value. Setting it to 4"); } } public int getMyGearCount(){ return myGearCount; } public String toString(){ return super.toString() + "The gearcount is " + myGearCount; } } class SkateBoard extends Vehicle{ private int myBoardLength; public SkateBoard(String b, String m, int bl){ super(b,m); myBoardLength = bl; } public int getMyBoardLength(){ return myBoardLength; } public void setMyBoardLength(int a){ myBoardLength = a; } public String toString(){ return super.toString() + "The board length is " + myBoardLength; } } class PoweredVehicle extends Vehicle{ private String myFuelType; public PoweredVehicle(String b, String m, String f){ super(b,m); myFuelType = f; } public String getFuelType(){ return myFuelType; } public void setFuelType(String f){ myFuelType = f; } public String toString(){ return super.toString() + "The fuel type is " + myFuelType; } } class Car extends PoweredVehicle{ private int myEngineSize; public Car(String b, String m, String f, int engineSize ){ super(b,m,f); if (engineSize >= 300) myEngineSize = engineSize; else{ System.out.println("Invalid value. Setting it as 300"); myEngineSize = 300; } } public int getMyEngineSize(){ return myEngineSize; } public void setMyEngineSize(int a){ if (a >= 300) myEngineSize = a; else System.out.println("Invalid size"); } public String toString(){ return super.toString() + "The engine size is " + myEngineSize + " cc"; } } class Jet extends PoweredVehicle{ private int myEngineCount; public Jet(String b, String m, String f, int engineCount ){ super(b,m,f); myEngineCount = engineCount ; } public String toString(){ return super.toString() + "The engine count is " + myEngineCount; } public int getMyEngineCount(){ return myEngineCount; } public void setMyEngineCount(int a){ myEngineCount = a; } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!