Implement an abstract class vehicle and concrete subclasses car and

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;

This program draws cars and trucks in random order.
public class RandomVehicleViewer
public static void main(String args[])
JFrame frame = new JFrame();
final int FRAME_WIDTH = 600;
final int FRAME_HEIGHT = 600;


JComponent component = new RandomVehicleComponent();

You need to supply the following classes in your solution:

Use the following class in your solution:
import java.awt.Graphics2D;

This class represents a vehicle.
public abstract class Vehicle
private int xleft;
private int ytop;

Construct a Vehicle object.
public Vehicle()
xleft = 0;
ytop = 0;

Draw the specified vehicle.
@param g2 the graphics context
public abstract void draw(Graphics2D g2);

Set the location of the vehicle.
@param x the x coordinate
@param y the y coordinate
public void setLocation(int x, int y)
xleft = x;
ytop = y;

Returns the x coordinate of the left-top corner of the vehicle
@return the x coordinate
public int getX()
return xleft;

Returns the y coordinate of the left-top corner of the vehicle
@return the y coordinate
public int getY()
return ytop;

public abstract int getHeight();
public abstract int getWidth();

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

mahjong ways 2