class Vehicle{
public int numberOfSeats;
public Vehicle()
{ }
public Vehicle(int x)
{
this.numberOfSeats = x;
}
public void driveCar(){
System.out.println("Driving vehicle for "+numberOfSeats+" people");
}
}
class Car extends Vehicle{
private String segment;
public Car()
{ }
public Car(String y)
{
this.segment= y;
}
public void driveCar() {
System.out.println("Driving "+segment+" segment vehicle");
}
}
public class VehicleTest{
public static void main(String [] args){
Vehicle v= new Vehicle(8);
Vehicle c= new Car("C");
v.driveCar();
c.driveCar();
}
}
public int numberOfSeats;
public Vehicle()
{ }
public Vehicle(int x)
{
this.numberOfSeats = x;
}
public void driveCar(){
System.out.println("Driving vehicle for "+numberOfSeats+" people");
}
}
class Car extends Vehicle{
private String segment;
public Car()
{ }
public Car(String y)
{
this.segment= y;
}
public void driveCar() {
System.out.println("Driving "+segment+" segment vehicle");
}
}
public class VehicleTest{
public static void main(String [] args){
Vehicle v= new Vehicle(8);
Vehicle c= new Car("C");
v.driveCar();
c.driveCar();
}
}
Yorumlar
Yorum Gönder