Пример #1
0
        static void Main(string[] args)
        {
            // construct engine
            Engine myEngine = new NuclearEngine();
            // construct navigation panel
            NavigationPanel myPanel = new NavigationPanel();

            // and define the travel route
            myPanel.AddPort("Szczecin", 1);
            myPanel.AddPort("Rotterdam", 3);
            myPanel.AddPort("Antwerp", 1);
            // construct submarine
            Submarine mySubmarine = new Submarine(myEngine, myPanel);

            mySubmarine.Recruit(4, 2);
            double cost = mySubmarine.RefillStocks(300.0, 100.0);

            // let's go!
            mySubmarine.Travel();
            // final station reached - buy some more supplies
            cost += mySubmarine.RefillStocks(50.0, 50.0);
            // how are we doing?
            mySubmarine.CheckSupplies();
            Console.WriteLine("Total cost so far: " + cost);
        }
Пример #2
0
 // constructor
 public Submarine(Engine eng, NavigationPanel panel)
 {
     crew         = new List <Human>();
     foodSupply   = new FoodSupply();
     oxygenSupply = new OxygenSupply(100000.0); // maximum oxygen capacity set to 100k
     genericWaste = new Waste("Generic");
     engine       = eng;                        // engine and navigation panel will be prepared somewhere else
     navPanel     = panel;
     equipment    = new List <ITool>()
     {
         navPanel
     };
 }