packagecar;publicclassCar{Stringbrand;doubleengineDisplacement;privatedoublespeed;booleanstatus;doublemaxSpeed;publicCar(){}publicCar(Stringbrand,doubleengineDisplacement...
package car;
public class Car
{
String brand;
double engineDisplacement;
private double speed;
boolean status;
double maxSpeed;
public Car(){}
public Car(String brand,double engineDisplacement,double maxSpeed)
{
this.brand=brand;
this.engineDisplacement=engineDisplacement;
this.maxSpeed=maxSpeed;
}
public void start()
{
status=true;
}
public void speedUp()
{
if(status==true)
{
speed=speed+5;
if(speed>maxSpeed)
speed=maxSpeed;
}
}
public void slowDown()
{
if(status==true)
{
speed=speed-5;
if(speed<0)
speed=0;
}
}
public void stop()
{
if(speed==0)
status=false;
}
}
package testcar;
import car.Car;
public class TestCar
{
public static void main(String args[])
{
Car a=new Car();
a.speed=1000;
System.out.println(a.speed);
}
}
Car类在Car.java的源文件中声明了包名car,TestCar类在TestCar.java 的源文件中 声明了包名testcar 然后TestCar类中包含了Car类的包car;
运行的时候要怎么输入命令啊 输入格式是怎么样的 javac 后面应该是什么呢?
展开