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, 04.07.2019 18:10
The drive force for diffusion is 7 fick's first law can be used to solve the non-steady state diffusion. a)-true b)-false
Answers: 1
question
Engineering, 04.07.2019 18:10
Burgers vector is generally parallel to the dislocation line. a)-true b)-false
Answers: 2
question
Engineering, 04.07.2019 18:10
Ahot wire operates at a temperature of 200°c while the air temperature is 20°c. the hot wire element is a tungsten wire of 5 um diameter and 2 mm in length. plot using excel current, heat transfer and heat generated by the wire for air velocity varying from 1-10 m/s in steps of lm/s? matlab the sensor voltage output, resistance, or assume nu 0.989 re033pr13 take air properties at tr (200°c20°c)/2 = 110°c properties of tungsten: c 0.13 kj/kg.k 3 p 19250 kg/m k (thermal conductivity) = 174 w/m.k
Answers: 2
question
Engineering, 04.07.2019 19:20
Acircular pipe of 30mm outside diameter is placed in an airstream at 30 c and latm pressure. the air moves in cross flow over the pipe at 20 m/s, while the outer surface of the pipe is maintained at 110 c. what is the drag force exerted on the pipe per unit length? what is the rate of heat transfer from the pipe per unit length?
Answers: 1
You know the right answer?
Write a class definition for an abstract class, Vehicle, that contains:

a double instanc...
Questions
Questions on the website: 13722360