コード例 #1
0
ファイル: Program.cs プロジェクト: tatupaaj/Olio-ohjelmointi
        static void TestCarWithFourWheelsV2()
        {
            // create tyre
            Rengas tyre1 = new Rengas {
                Merkki = "Nokia", Tyyppi = "Hakkapeliitta", RengasKoko = "205R16"
            };
            // create a car
            Auto auto = new Auto {
                Merkki = "Porsche", Malli = "911"
            };

            Console.WriteLine("Luotu uusi pirssi {0} {1}", auto.Merkki, auto.Malli);
            auto.LisaaRengas(tyre1);
            auto.LisaaRengas(tyre1);
            auto.LisaaRengas(tyre1);
            auto.LisaaRengas(tyre1);
            Console.WriteLine(auto.ToString());
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: K8980/Labra2-3
        static void Main(string[] args)
        {
            List <Auto> autot = new List <Auto>();

            bool poop = true;

            Auto   tempAuto;
            Rengas tempRengas;

            for (int i = 0; i < 2; i++)
            {
                tempAuto = new Auto(4);

                Console.WriteLine("Auton Merkki");
                tempAuto.Merkki = Console.ReadLine();

                Console.WriteLine("Auton Malli");
                tempAuto.Malli = Console.ReadLine();

                for (int y = 0; y < tempAuto.RenkaidenLkm; y++)
                {
                    tempRengas            = new Rengas();
                    tempRengas.Valmistaja = "Nokia";
                    tempRengas.Malli      = "3110";
                    tempRengas.Rengaskoko = 15;
                    tempRengas.Tyyppi     = "Talvi";
                    tempAuto.LisaaRengas(tempRengas);
                }
                autot.Add(tempAuto);
            }

            foreach (Auto a in autot)
            {
                Console.WriteLine("Merkki: " + a.Merkki + ", Malli: " + a.Malli);
                foreach (Rengas r in a.Renkaat)
                {
                    Console.WriteLine("Renkaan valmistaja: " + r.Valmistaja + ", malli: " + r.Malli + ", tyyppi: " + r.Tyyppi + ", koko: " + r.Rengaskoko);
                }
            }
        }