static void Main(string[] args) { WeatherStation weatherStation = new WeatherStation(); NewsAgency channel11 = new NewsAgency("Channel 11"); NewsAgency channel12 = new NewsAgency("Channel 12"); NewsAgency channel13 = new NewsAgency("Channel 13"); weatherStation.Attach(channel11); weatherStation.Attach(channel12); weatherStation.Attach(channel13); bool endProgram = false; while (!endProgram) { Console.WriteLine("Press X For Exit OR Insert Update Temperature:"); var tempRead = Console.ReadLine(); if (tempRead.Equals("X")) { endProgram = true; } else { float.TryParse(tempRead, out float temp); weatherStation.Temperature = temp; } } weatherStation.UnRegister(channel11); weatherStation.UnRegister(channel12); weatherStation.UnRegister(channel13); }
public void RegisterNewsAgency(NewsAgency newsAgency) { try { _context.NewsAgencies.Add(newsAgency); _context.SaveChanges(); } catch (Exception) { throw; } }
public static void TestRun() { WeatherStation weatherStation = new WeatherStation(); NewsAgency agency1 = new NewsAgency("Alpha News Agency"); weatherStation.Attach(agency1); NewsAgency agency2 = new NewsAgency("Omega News Agency"); weatherStation.Attach(agency2); weatherStation.Temperature = 31.2f; weatherStation.Temperature = 28.5f; weatherStation.Temperature = 33.1f; weatherStation.Temperature = 29.2f; Console.ReadLine(); }
public void RegisterNewsAgencyForInternal(NewsAgency newsAgency) { _internalNewsRepository.RegisterNewsAgency(newsAgency); }
public void RegisterNewsAgencyForPressTrustOfIndia(NewsAgency newsAgency) { _pressTrustOfIndiaNewsRepository.RegisterNewsAgency(newsAgency); }
public void RegisterNewsAgencyForGoogle(NewsAgency newsAgency) { _googleNewsRepository.RegisterNewsAgency(newsAgency); }
static void Main(string[] args) { NewsAgency agency = new NewsAgency(); MusicNowChannel ch1 = new MusicNowChannel(agency); NewsChannel1 ch2 = new NewsChannel1(agency); NewsChannel2 ch3 = new NewsChannel2(agency); SportsChannel ch4 = new SportsChannel(agency); agency.Report(new News() { Message = "COVID Vaccine created", NewsType = News.NType.Health, Reporter = "Reporter1" }); Console.WriteLine("\n-------------------------------------------------------------------\n"); agency.Report(new News() { Message = "Bahamas now open for travellers", NewsType = News.NType.Travel, Reporter = "Reporter1" }); Console.WriteLine("\n-------------------------------------------------------------------\n"); agency.Report(new News() { Message = "New Season of IPL starting in August", NewsType = News.NType.Sports, Reporter = "Reporter1" }); Console.WriteLine(); ch1.BeginMusicConcert(); Console.WriteLine(); agency.Report(new News() { Message = "A new movie is releasing shortly", NewsType = News.NType.Entertainment, Reporter = "Reporter1" }); Console.WriteLine("\n-------------------------------------------------------------------\n"); agency.Report(new News() { Message = "All Nations sign the Paris Environment treaty", NewsType = News.NType.Politics, Reporter = "Reporter1" }); Console.WriteLine("\n-------------------------------------------------------------------\n"); agency.Report(new News() { Message = "The new iPhone hits the market this December", NewsType = News.NType.Tech, Reporter = "Reporter1" }); Console.WriteLine(); ch1.EndMusicConcert(); Console.WriteLine(); agency.Report(new News() { Message = "The Music Concert was a great Success!!", NewsType = News.NType.Entertainment, Reporter = "Reporter1" }); Console.WriteLine("\n-------------------------------------------------------------------\n"); }