×

vehicles 应用程序

vehicles(编写一个Java应用程序,设计一个汽车类Vehicle)

jnlyseo998998 jnlyseo998998 发表于2022-09-25 05:40:14 浏览112 评论0

抢沙发发表评论

本文目录

编写一个Java应用程序,设计一个汽车类Vehicle

class Vehicle {

int wheels;

float weight;

protected Vehicle(int wheels, float weight){

this.wheels = wheels;

this.weight = weight;

}

public void print(){

System.out.println(“汽车共有“+wheels+“个轮子“);

System.out.println(“重量为“+weight+“吨“);

}

}

class Car extends Vehicle{

int loader;

public Car(int wheels, float weight, int load) {

super(wheels, weight);

loader = load;

}

@Override

public void print(){

System.out.println(“小车共有“+wheels+“个轮子“);

System.out.println(“重量为“+weight+“吨“);

System.out.println(“载人数为“+ loader+“人“);

}

}

class Truck extends Car{

float payload;

public Truck(int wheels, float weight, int loader, float payload) {

super(wheels, weight, loader);

this.loader= loader;

this.payload = payload;

}

@Override

public void print(){

System.out.println(“卡车:共有“+wheels+“个轮子“);

System.out.println(“重量为“+weight+“吨“);

System.out.println(“载人数为“+loader+“人“);

System.out.println(“载重量为“+payload+“吨“);

}

}

public class Text{

public static void main(String args){

Vehicle car = new Car(4, 3, 4);

Vehicle truck = new Truck(6, 6, 2, 10);

car.print();

truck.print();

}

}

the bicycle is one of the most important vehicles in the world怎么读

您好 很高兴回答您的问题 读作 THE BICYCLE IS ONE OF THE MOST IMPORTANTA VIHICAL INTHE WORLD