예제 #1
0
    static void Main(string[] args)
    {
        Alarm   alarm   = new Alarm();
        Baterai baterai = new Baterai();

        baterai.Kapsitas = 35;

        alarm.Baterai = baterai;
        Console.WriteLine(alarm.Baterai.Kapsitas);

        //int jam = alarm.AmbilWaktu("jam");
        //jam *= 2;
        //Console.WriteLine(jam);

        if (alarm.GetKondisiAlarm())
        {
            if (alarm.Baterai.Kapsitas < 40)
            {
                Console.WriteLine("Baterai Melemah");
            }
            else
            {
                Console.WriteLine(alarm.MenunjukanWaktu());
            }
        }
        else
        {
            Console.WriteLine("Alarm Mati, hidupkan terlebih dahulu");
        }

        Console.ReadKey();
    }
예제 #2
0
 public Alarm(Baterai baterai, bool hidupkan)
 {
     totalAlarm++;
     this.baterai = baterai;
     Console.WriteLine("Baterai dimasukan, dengan kapasitas " + baterai.Kapsitas);
     this.hidup = hidupkan;
     Console.WriteLine("Alarm " + (hidupkan ? "dihidupkan" : "tidak dihidupkan"));
     Console.WriteLine("Machine Code : " + machineCode);
 }
예제 #3
0
 public Alarm()
 {
     totalAlarm++;
     Console.WriteLine("Objek Alarm Dibuat");
     Console.WriteLine("Memasang Baterai");
     this.baterai = new Baterai {
         Kapsitas = 100
     };
     Console.WriteLine("Menyalakan Alarm . . .");
     this.hidup  = true;
     this.bentuk = "Kotak";
     Console.WriteLine("Alarm Siap Digunakan, dengan kapasitas baterai " + this.baterai.Kapsitas);
     Console.WriteLine("Machine Code : " + machineCode);
 }
예제 #4
0
    static void Main(string[] args)
    {
        Baterai baterai = new Baterai {
            Kapsitas = 75
        };
        Alarm alarm = new Alarm(baterai, false);

        Alarm.Count();
        Alarm alarm2 = new Alarm();

        Alarm.Count();
        Alarm.machineCode = "MOVFFF0X";
        Alarm alarm3 = new Alarm();

        Alarm.Count();
        Alarm alarm4 = new Alarm();

        Alarm.Count();

        Console.ReadKey();
    }