static void Main(string[] args) { RadioStation rs1 = new RadioStation("Radio Classic", "test", new FmFrequencyBand(99, null)); RadioStation rs2 = new RadioStation("Radio Classic", "test", new FmFrequencyBand(99.8, 100)); RadioPlayerApp rpa = new RadioPlayerApp(); rpa.Add(rs1); rpa.Add(rs2); rpa.LikeRadioStation(rs1.stationName); rpa.Play(rs1.stationName); rpa.Pause(rs1.stationName); Console.ReadLine(); }
/// <summary> /// Like a station from the list of stations and therefore add it to the end of their list of favourite stations /// </summary> /// <param name="stationName">Station name</param> public void LikeRadioStation(string stationName) { RadioStation found = this.RpaList.Where(x => x.stationName.Equals(stationName)).FirstOrDefault(); if (found != null) { RadioStation foundinFav = this.favouriteStationList.Where(x => x.stationName.Equals(stationName)).FirstOrDefault(); if (foundinFav == null) { favouriteStationList.Add(found); } else { favouriteStationList.Remove(found); favouriteStationList.Add(found); } } else { Console.WriteLine("Radion station {0} not found.", stationName); } }
/// <summary> /// Add station band /// </summary> /// <param name="rpApp">Radio player app object</param> public void Add(RadioStation rpApp) { bool stationNameDuplicated = false; if (!RpaList.Contains(rpApp) && rpApp.stationFrequency.isInRange) { foreach (RadioStation radioStation in RpaList) { if (radioStation.stationName.Equals(rpApp.stationName)) { stationNameDuplicated = true; break; } } if (!stationNameDuplicated) { this.RpaList.Add(new RadioStation(rpApp.stationName, rpApp.stationGenre, rpApp.stationFrequency)); } } }
public void Pause(string stationName) { RadioStation found = this.RpaList?.Where(x => x.stationName.Equals(stationName)).FirstOrDefault(); found.Pause(); }