创建一个汽车类,必须包含以下非静态私有成员:
 属性: 颜色--color(String 型),牌子---brand(String型),是否机动车(boolean型)---isAuto,汽油量(double型)----oil
非静态公开方法:starting(在启动)、
静态公开方法:running(在跑)、 ***
非静态公开方法:stopping(在停止)、
注意,
1. 行驶的时候必须分机动和非机动车
2. 行驶过程油量会减少
3. 汽油用完了汽车会停止,必须考虑这些因素
4. 汽车开始或停止必须要先判断汽车的状态,例如如果汽车是停止的就不停执行stopping, 而汽车在开就不能运行starting或running....
请实现以上的功能(打印在控制台上...)

解决方案 »

  1.   

    我在想,你老人家总共0分...我这帮你做了岂不是捞不到任何好处?!
    但是出于国际主义决定帮你写了
    只是你的要求太简单贴出来岂不是丢人!?
    纠结啊,为让自己不纠结,还是贴了吧
    但是但是。package jp.co.nec.nems.northbound.common.mapping;public class Car implements Runnable{
        
        /**
         * you car use 1 L per second.
         */
        public static final double HAO_YOU_LIANG = 1;    private String color_ = "red";    private String brand = "BMW";    private boolean isAuto = true;    private double oil = 10;
        
            public void starting(){
            System.out.println("the car is starting....");
        }
        
        public static void running(){
            Car car = new Car();
            car.starting();
            car.run();
            
        }
        
        public void stopping(){
            System.out.println("the car is stopped.");
        }
        
        
        public static void main(String[] args){
            running();
        }    
        public void run() {
           for( ; ; ){
               try {
                Thread.sleep(1000);
               
            } catch ( InterruptedException e ) {
                System.out.println("omg!");
            }
            System.out.println("the car is running....");
            oil -= HAO_YOU_LIANG;
            if(oil <=0){
                new Car().stopping();
                break;
            }
           }
            
        }
    }
      

  2.   

    lz不都说了么,新手么
    还用不到线程吧
    得怪lz,都么说清楚