Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Colos2
- {
- class Osoba
- {
- public string Imie { get; set; }
- public string Nazwisko { get; set; }
- public Osoba(string Imie, string Nazwisko)
- {
- this.Imie = Imie;
- this.Nazwisko = Nazwisko;
- }
- }
- class Pokoj
- {
- public int Numer { get; set; }
- public int LiczbaOsob { get; set; }
- public bool Rezerwacja { get; set; }
- public Osoba Gosc { get; set; }
- public Pokoj()
- {
- Gosc = new Osoba(null, null);
- }
- public Pokoj(int Numer, int LiczbaOsob)
- {
- this.Numer = Numer;
- this.LiczbaOsob = LiczbaOsob;
- Rezerwacja = false;
- Gosc = new Osoba(null, null);
- }
- public string CzyZarezerwowany()
- {
- if (Rezerwacja == true)
- return string.Format("zarezerwowany");
- else
- return string.Format("wolny");
- }
- public void Rezerwuj(string Imie, string Nazwisko)
- {
- Gosc = new Osoba(Imie, Nazwisko);
- Rezerwacja = true;
- }
- public string InfoPokoj()
- {
- if (Rezerwacja == true)
- return string.Format("Pokoj numer {0} jest {1} osobowy, jest {2} dla goscia Oskar Niewadzisz.", this.Numer, this.LiczbaOsob, this.CzyZarezerwowany());
- else
- return string.Format("Pokoj numer {0} jest {1} osobowy, jest {2}.", this.Numer, this.LiczbaOsob, this.CzyZarezerwowany());
- }
- public override string ToString()
- {
- return string.Format("Pokoj o numerze: {0}. Jest {1}", this.Numer, this.CzyZarezerwowany());
- }
- }
- class Hotel
- {
- public List<Pokoj> Pokoje { get; set; }
- public Hotel()
- {
- Pokoje = new List<Pokoj>();
- }
- public Hotel(int Numer, int LiczbaOsob)
- {
- Pokoje = new List<Pokoj>();
- Pokoj pokoj = new Pokoj(Numer, LiczbaOsob);
- Pokoje.Add(pokoj);
- }
- public void DodajPokoj(int Numer, int LiczbaOsob)
- {
- Pokoj pokoj = new Pokoj(Numer, LiczbaOsob);
- Pokoje.Add(pokoj);
- }
- public void RezerwujPokoj(int N, string Imie, string Nazwisko)
- {
- Pokoje.Find(k => k.Numer == N).Rezerwuj(Imie, Nazwisko);
- }
- public void WyswietlPokoje()
- {
- for (int i = 0; i < Pokoje.Count; i++)
- {
- Console.WriteLine(Pokoje[i]);
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Pokoj pokoj = new Pokoj(3, 1);
- Console.WriteLine(pokoj.InfoPokoj());
- pokoj.Rezerwuj("Oskar", "Niewadzisz");
- Console.WriteLine(pokoj.InfoPokoj());
- Console.WriteLine("\n-----------------------------------------------------");
- Hotel hotel = new Hotel();
- hotel.DodajPokoj(1, 1);
- hotel.DodajPokoj(2, 2);
- hotel.DodajPokoj(3, 3);
- hotel.RezerwujPokoj(3, "Oskar", "Niewadzisz");
- hotel.WyswietlPokoje();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement