Implement an abstract class vehicle


Discuss teh below:

Q: Implement an abstract class Vehicle and concrete subclasses Car and Truck. A vehicle has a position on the screen. Write methods draw that draw cars and trucks as follows:

Then write a method randomVehicle that randomly generates Vehicle references, with an equal probability for constructing cars and trucks, with random positions. Call it 10 times and draw all of them.

Use the following class as your main class:
import javax.swing.JComponent;
import javax.swing.JFrame;

 

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Implement an abstract class vehicle
Reference No:- TGS01933942

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)