static void Main(string[] args) { Radio radio = new Radio(); Console.Write("Power (on/off) = "); string power = Console.ReadLine(); if (power == "on") radio.PowerOn = true; else radio.PowerOn = false; Console.Write("Set volume (0 - 9) = "); radio.Volume = int.Parse(Console.ReadLine()); Console.Write("Set frequency (2000,0 - 26 000,0) = "); radio.Frequency = float.Parse(Console.ReadLine()); radio.PrintData(); }
static void Main(string[] args) { int volume; double frequency; Radio radio = new Radio(); Console.Write("Turn the radio on by typing on > "); string turnon = Console.ReadLine(); if (turnon == "on") radio.On(); else Console.WriteLine("You didn't turn the radio on!"); Console.Write("Set radio volume > "); string volumeset = Console.ReadLine(); bool result = int.TryParse(volumeset, out volume); if (result) radio.Volume = volume; else Console.WriteLine("You didn't give a number!"); Console.Write("Set radio frequency > "); string freqset = Console.ReadLine(); bool result2 = double.TryParse(freqset, out frequency); if (result2) radio.Frequency = frequency; else Console.WriteLine("You didn't give a number!"); radio.PrintData(); /* TULOSTAA ESIM: Turn the radio on by typing on > on Radio is now on! Set radio volume > 3 Set radio frequency > 100 Frequency is too small, set to min Radio information: - Is on: True - Volume: 3 - Frequency: 2000 */ }