package com.hanqi.test;
public class Car {
private String carNo;
private int speed;
private double support;
public Car()
{
carNo="XX1234";
speed=100;
support=100;
}
public Car(String c,int sp,double su)
{
carNo=c;
speed=sp;
support=su;
}
public void highSpeed(int sp)
{
speed+=sp;
}
public void lowSpeed(int sp)
{
if(speed>=sp)
{
speed-=sp;
}
else
{
System.out.println("时速已经不够"+sp);
}
}
public void changeCarNo(String bb)
{
carNo=bb;
}
public void showSupport()
{
System.out.println("载重"+support);
}
public void show()
{
System.out.println("车牌号:"+carNo+",车速:"+speed+",载重:"+support);
}
}
//主类
package com.hanqi.test;
public class TestCar {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Car c=new Car();
c.changeCarNo("辽A9752");
c.show();
c.highSpeed(30);
c=new Car("辽B5086",150,200);
c.lowSpeed(100);
c.show();
}
}
//运行结果
车牌号:辽A9752,车速:100,载重:100.0
车牌号:辽B5086,车速:50,载重:200.0