Exemplo n.º 1
0
 static void Main(string[] args)
 {
     Radio phillips = new Radio();
     int menu = 1;
     string vol;
     while (menu != 0)
     {
         if(phillips.Power==true)
         {
             vol = "On";
         }
         else
         {
             vol = "Off";
         }
         Console.WriteLine("Radio\n-----\n1.Toggle power          Power: {0}\n2.Change volume         Volume: {1}\n3.Change frequency      Frequency: {2}\n0.Exit", vol, phillips.Volume,phillips.Frequency);
         menu = int.Parse(Console.ReadLine());
         switch (menu)
         {
             default:
                 Console.WriteLine("Unknown command");
                 break;
             case 0:
                 break;
             case 1:
                 if (phillips.Power == true)
                 {
                     phillips.Power = false;
                 }
                 else
                 {
                     phillips.Power = true;
                 }
                 break;
             case 2:
                 if (phillips.Power == true)
                 {
                     Console.Write("Set new volume: ");
                     phillips.Volume = int.Parse(Console.ReadLine());
                 }
                 else
                 {
                     Console.WriteLine("The radio isn't on");
                 }
                 break;
             case 3:
                 if (phillips.Power == true)
                 {
                     Console.Write("Set new frequency: ");
                     phillips.Frequency = double.Parse(Console.ReadLine());
                 }
                 else
                 {
                     Console.WriteLine("The radio isn't on");
                 }
                 
                 break;
         }
     }
 }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     Radio volume = new Radio();
     volume.Volume = 1; // 0 = Radio pois päältä, 1-10 = Radio päällä ja volume = arvo*10
     Radio frequency = new Radio();
     frequency.Frequency = 20000; // Aseta taajuus välille 2000-26000
     Console.ReadLine();
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //luodaan radio
            Radio radio = new Radio();
            Console.Write("Anna taajuus jota kuunnella:");
            string hz = Console.ReadLine();
            int freaquency = int.Parse(hz);
            radio.Freaquency = freaquency;
            Console.ReadLine();


            //luodaan volyme

            Volyme volyme = new Volyme();
            Console.Write("Anna äänenvoimakkuus jolla kuunnella:");
            string vol = Console.ReadLine();
            int Volyme = int.Parse(vol);
            volyme.Vol = vol;

            
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            //luodaan radio
            Radio radio = new Radio();

            Console.Write("Anna taajuus jota kuunnella:");
            string hz         = Console.ReadLine();
            int    freaquency = int.Parse(hz);

            radio.Freaquency = freaquency;
            Console.ReadLine();


            //luodaan volyme

            Volyme volyme = new Volyme();

            Console.Write("Anna äänenvoimakkuus jolla kuunnella:");
            string vol    = Console.ReadLine();
            int    Volyme = int.Parse(vol);

            volyme.Vol = vol;
        }