subject
Engineering, 28.02.2020 03:14 teethebeast

Write a class definition for an abstract class, Vehicle, that contains:

a double instance variable, maxSpeed
a protected double instance variable, currentSpeed
a constructor accepting a double used to initialize the maxSpeed instance variable
an abstract method, accelerate, that accepts no parameters and returns nothing.
a method getCurrentSpeed that returns the value of currentSpeed
a method getMaxSpeed that returns the value of maxSpeed
a method, pedalToTheMetal, that repeatedly calls accelerate until the speed of the vehicle is equal to maxSpeed. pedalToTheMetal returns nothing.

The main program written below will call the class methods. You need to just write the class as mentioned above.
import java. util. Scanner;

///{
//write your code here
//start

//end
///}
public class testdemo extends Vehicle{

public testdemo(double no){
super(no);
}
void accelerate(){
System. out. print(currentSpeed+" ");
currentSpeed++;
}

public static void main(String[] arg){
Scanner scanner =new Scanner(System. in);
System. out. println("Enter the number:");
int n=scanner. nextInt();
testdemo td=new testdemo(n);
System. out. println("Current Speed:"+td. getCurrentSpeed());
System. out. println("Max Speed:"+td. getMaxSpeed());
td. pedalToTheMetal();

}

}

ansver
Answers: 2

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Heat is added to a piston-cylinder device filled with 2 kg of air to raise its temperature 400 c from an initial temperature of t1 27 cand pressure of pi 1 mpa. the process is isobaric process. find a)-the final pressure p2 b)-the heat transfer to the air.
Answers: 1
question
Engineering, 04.07.2019 18:10
Apipe with an outside diameter of 15 cm is exposed to an ambient air and surrounding temperature of -20°c. the pipe has an outer surface temperature of 65°c and an emissivity of 0.85. if the rate of heat loss from the pipe surface is 0.95 kw per meter of length, the external convective heat transfer coefficient (h) is: (a) 12.5 w/m"k (b) 18.6 w/mk (c) 23.7 w/mk (d) 27.9 w/mk (e) 33.5 w/mk
Answers: 1
question
Engineering, 04.07.2019 18:10
The filament of an incandescent lamp has a temperature of 2000k. calculate the fraction of radiation emitted in the visible light band if the filament is approximated as blackbody
Answers: 2
question
Engineering, 04.07.2019 18:20
Select any two (2) areas of applications of chain-drive. (clo4) a)-permanent lubrication necessary b)-hydraulic forklift truck operation c)-rigging and heavy moving materials d)-relatively high maintenance costs e)-costlier than belt drives
Answers: 2
You know the right answer?
Write a class definition for an abstract class, Vehicle, that contains:

a double instanc...
Questions
question
Mathematics, 26.03.2021 20:10
question
Mathematics, 26.03.2021 20:10
question
Mathematics, 26.03.2021 20:10
question
Biology, 26.03.2021 20:10
Questions on the website: 13722363