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

Advances In Database Technology Edbt 88 International Conference On Extending Database Technology Venice Italy March 14 18 1988 Proceedings Lncs 303

Authors: Joachim W. Schmidt ,Stefano Ceri ,Michele Missikoff

1988th Edition

3540190740, 978-3540190745

More Books

Students also viewed these Databases questions

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago