Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hi i need help to this code when i run there i an error in vehicle rental class and the main class this is the

hi i need help to this code

when i run there i an error in vehicle rental class

and the main class

this is the full code

interface Vehicle {

void drive();

void start();

void stop();

}

class Van implements Vehicle {

@Override

public void drive() {

System.out.println("Driving the van...");

}

@Override

public void start() {

System.out.println("Starting the van...");

}

@Override

public void stop() {

System.out.println("Stopping the van...");

}

}

class Car implements Vehicle {

@Override

public void drive() {

System.out.println("Driving the car...");

}

@Override

public void start() {

System.out.println("Starting the car...");

}

@Override

public void stop() {

System.out.println("Stopping the car...");

}

}

class MotorCycle implements Vehicle {

@Override

public void drive() {

System.out.println("Driving the motorcycle...");

}

@Override

public void start() {

System.out.println("Starting the motorcycle...");

}

@Override

public void stop() {

System.out.println("Stopping the motorcycle...");

}

}

class VehicleRental {

public void rent(Vehicle v) {

v.drive();

}

}

public class Main {

public static void main(String[] args) {

VehicleRental vr1 = new VehicleRental<>();

vr1.rent(new Car());

VehicleRental vr2 = new VehicleRental<>();

vr2.rent(new Van());

VehicleRental vr3 = new VehicleRental<>();

vr3.rent(new MotorCycle());

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Postgresql 16 Administration Cookbook Solve Real World Database Administration Challenges With 180+ Practical Recipes And Best Practices

Authors: Gianni Ciolli ,Boriss Mejias ,Jimmy Angelakos ,Vibhor Kumar ,Simon Riggs

1st Edition

1835460585, 978-1835460580

More Books

Students also viewed these Databases questions

Question

1. Briefly describe the major social networking services.

Answered: 1 week ago

Question

b. Determine the 95% confidence intervals for the parameters.

Answered: 1 week ago