Question
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.rent(new Car());
VehicleRental
vr2.rent(new Van());
VehicleRental
vr3.rent(new MotorCycle());
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started