public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Rover      rover      = new Rover();
            Battery    battery    = new Battery();
            Drill      drill      = new Drill();
            SolarPanel solarPanel = new SolarPanel();
            Radar      radar      = new Radar();

            Console.WriteLine(rover.Batteries.Count);

            rover.Attach(radar);
            radar.ConnectBattery(rover.Batteries[0]);

            rover.Operate();
            rover.Operate();
            rover.Operate();
            rover.Operate();
            rover.Operate();
            rover.Operate();
            rover.Operate();
            rover.Operate();
            rover.Operate();

            Console.ReadLine();
        }
示例#2
0
        public Rover(int x, int y, int size, string name, Environment env) : base(x, y, size, name, env)
        {
            _devices   = new List <Device>();
            _extracted = new List <Specimen>();
            _batteries = new List <Battery>();
            _batteries.Add(new Battery("Battery 1"));
            _batteries.Add(new Battery("Battery 2"));

            Drill         drill         = new Drill("Drill", this);
            Motor         downMotor     = new Motor("Downward Motor", EDirection.Down, this);
            Motor         upMotor       = new Motor("Upward Motor", EDirection.Up, this);
            Motor         leftMotor     = new Motor("Leftward Motor", EDirection.Left, this);
            Motor         rightMotor    = new Motor("Rightward Motor", EDirection.Right, this);
            LocationRadar locationRadar = new LocationRadar("Location Radar", env, this);
            SizeRadar     sizeRadar     = new SizeRadar("Size Radar", env, this);
            NameRadar     nameRader     = new NameRadar("Name Radar", env, this);
            Solar         solar         = new Solar("Solar Panel", this);

            _devices.Add(drill);
            _devices.Add(downMotor);
            _devices.Add(upMotor);
            _devices.Add(leftMotor);
            _devices.Add(rightMotor);
            _devices.Add(locationRadar);
            _devices.Add(sizeRadar);
            _devices.Add(nameRader);
            _devices.Add(solar);


            _selected = false;
        }