看不穿你的灵魂吧 关注:2,522贴子:835
  • 1回复贴,共1
public class Vehile
{
double speed;
int power;
void speedUp(int s)
{
speed=s+speed;
}
void speedDown(int d)
{
speed=speed-d;
}
int setPower(int p)
{
power=p;
}
int getPower()
{
return power;
}
double getSpeed()
{
return speed;
}
}


IP属地:山东1楼2017-09-11 20:52回复
    public class User {
    public static void main(String[] args) {
    Vehile car;
    car=new Vehile();
    car.speedUp(20);
    car.setPower(40);
    System.out.println("速度:"+car.getSpeed());
    car.speedDown(33);
    System.out.println("速度:"+car.getPower());
    }
    }


    IP属地:山东2楼2017-09-11 20:53
    回复