Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

// 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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions