package com.zhiyou100;
public class Vehicle {
//速度
int speed;
//品牌
String brand;
//体积
int size;
//移动功能
public void move(){}
public void setSpeed(int s){
speed = s;
}
public int speedUp(){
return speed = speed + 10;
}
public int speedDown(){
return speed = speed - 10;
}
public static void main(String[] args) {
Vehicle A =new Vehicle();
A.speed = 100;
A.brand ="Rolls-Royce";
A.size = 10;
System.out.println("这辆车的速度为"+A.speed+",这辆车的牌子为"+A.brand+",这辆车的体积为"+A.size);
int up = A.speedUp();
System.out.println("这辆车加速后的速度为"+up);
int down = A.speedDown();
System.out.println("这辆车减速后的速度为"+down);
}
}
java设计程序定义交通工具类(Vehicle)
最新推荐文章于 2023-11-24 14:03:41 发布