Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Selamat Datang!");
            Console.WriteLine("====================================");
            Customer customer1 = new Customer();

            Console.Write("Nama: ");
            customer1.Nama = Console.ReadLine();
            Mobil mobil1 = new Mobil();

            Console.Write("Masukkan jumlah kursi mobil yang diinginkan: ");
            mobil1.SeatCount = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("====================================");
            MobilTersedia[] listMobil = new MobilTersedia[5];
            SetStock.readStock(listMobil);
            CariMobil.cariMobil(listMobil, mobil1.SeatCount);
            Paket[] listPaket = new Paket[3];
            TampilPaket.tampilkanPaket(listMobil, listPaket);
            Console.WriteLine("====================================");
            Console.Write("Masukkan pilihan mobil: ");
            int i = Convert.ToInt32(Console.ReadLine());

            Console.Write("Masukkan pilihan paket: ");
            int j = Convert.ToInt32(Console.ReadLine());

            Console.Write("Masukkan jumlah mobil : ");
            int        jlh  = Convert.ToInt32(Console.ReadLine());
            DetailSewa sewa = new DetailSewa();

            sewa.Nama   = listMobil[i - 1].nama;
            sewa.Paket  = listPaket[j - 1].nama;
            sewa.Tarif  = listPaket[j - 1].tarif;
            sewa.Jumlah = jlh;
            int total = sewa.tampilkan();

            Console.Write("Buat pesanan? [ya/tidak]: ");
            string konf = Console.ReadLine();

            if (konf == "ya")
            {
                Pembayaran.bayar(total);
            }
            listMobil[i - 1].stock = (listMobil[i - 1].stock) - jlh;
            SetStock.writeStock(listMobil);
            sewa.setLog(customer1.Nama);
        }
Пример #2
0
        public static void readStock(MobilTersedia[] listMobil)
        {
            int[]        array = new int[10];
            int          i     = 0;
            StreamReader sr    = new StreamReader(Directory.GetCurrentDirectory() + "\\Stock.txt");
            string       line  = sr.ReadLine();

            while (line != null)
            {
                array[i] = Convert.ToInt32(line);
                line     = sr.ReadLine();
                i++;
            }
            sr.Close();
            //MobilTersedia[] listMobil = new MobilTersedia[5];
            listMobil[0] = new MobilTersedia("AAA", 7, array[0]);
            listMobil[1] = new MobilTersedia("BBB", 3, array[1]);
            listMobil[2] = new MobilTersedia("CCC", 4, array[2]);
            listMobil[3] = new MobilTersedia("DDD", 3, array[3]);
            listMobil[4] = new MobilTersedia("EEE", 6, array[4]);
        }