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
Ahouse has the following electrical appliance usage (1) single 40w lamp used for 4 hours per day (2) single 60w fan used for 12 hours per day (3) single 200w refrigerator that runs 24 hours per day with compressor run 12 hours and off 12 hours find the solar power inverter size in watt with correction factor of 1.25.
Answers: 1
question
Engineering, 04.07.2019 18:10
Afluid flows with a velocity field given by v=(x/t)i.. determine the local and convective accelerations when x=3 and t=1.
Answers: 2
question
Engineering, 04.07.2019 18:10
Courses that are developed by subject matter experts, internal or extemal to the college or university. these programs are marketed by the school (clo2) marks a)-vocational schools b)-vendor training c)-colleges & universities d)-continuing education programs
Answers: 2
question
Engineering, 04.07.2019 18:20
Asolid cylinder is concentric with a straight pipe. the cylinder is 0.5 m long and has an outside diameter of 8 cm. the pipe has an inside diameter of 8.5 cm. the annulus between the cylinder ad the pipe contains stationary oil. the oil has a specific gravity of 0.92 and a kinematic viscosity of 5.57 x 10-4 m2/s. most nearly, what is the force needed to move the cylinder along the pipe at a constant velocity of 1 m/s?
Answers: 3
You know the right answer?
Write a class definition for an abstract class, Vehicle, that contains:

a double instanc...
Questions
question
Mathematics, 11.10.2019 23:40
question
Chemistry, 11.10.2019 23:50