using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace KonKopiujący { class Komputer { public bool stan; public string colour; public double processor; public int graphic; public Komputer() { stan = false; processor = 3.16; graphic = 2048; } public void Check() { if(stan) { Console.WriteLine("Komputer jest wlaczony!"); } else { Console.WriteLine("Komputer jest wylaczony!"); } if(processor==3.16 && graphic==2048) { Console.WriteLine("Procesor i grafika w trybie oszczędności energii "); } else { Console.WriteLine("Procesor i grafika w trybie wyższej wydajności"); } } public void Start() { if(stan) { stan = false; } else { stan = true; } } public void Tryb() { if (stan) { if (processor == 3.16 && graphic == 2048) { processor = 3.16; graphic = 4096; } else { processor = 3.16; graphic = 2048; } } else { Console.WriteLine("Komputer jest wylaczony!"); } } private void Boost(Komputer x) { x.processor += 3.55; x.graphic += 6144; } public Komputer(Komputer x) { this.stan = x.stan; this.processor = x.processor; this.graphic = x.graphic; } ~Komputer() { Console.WriteLine("Konstruktor Komputer"); } } class Mp3 { bool stan; bool battery; public int songs; public int memory; public Mp3() { stan = false; battery = true; songs = 666; memory = 1024; } public void Start() { if (stan) { stan = false; } else { stan = true; } } public void Check() { if(stan&&battery) { Console.WriteLine("Urzadzenie jest wlaczone!"); } else { Console.WriteLine("Urzadzenie jest wylaczone!"); } if (battery) { Console.WriteLine("Baterie sa wlozone!"); } else { Console.WriteLine("Brak bateri!"); } Console.WriteLine("W pamieci jest: " + songs); Console.WriteLine("Pamiec wynosi: " + memory); } public void Dokup() { Console.WriteLine("Ile losowych piosenek chcesz dokupić?"); int x = 0; x = int.Parse(Console.ReadLine()); Console.WriteLine("Dokupiono " + x + " nowych piosenek! Miłego słuchania!"); songs = songs + x; } public Mp3 (Mp3 x) { this.stan = x.stan; this.battery = x.battery; this.songs = x.songs; this.memory = x.memory; } private void Boost () { memory += 2048; } ~Mp3() { Console.WriteLine("Konstruktor MP3"); } } class Program { static void Prezent(Komputer x, Mp3 y) { string imie; int wybor; Console.WriteLine("Dla kogo chcesz kupić prezent? Podaj imie: "); imie=Console.ReadLine(); Console.WriteLine("Wpisz 1, jeśli chcesz podarować komputer. Wpisz 2, jeśli chcesz podarować Mp3"); wybor = int.Parse(Console.ReadLine()); if (wybor == 1) { Komputer Nowy = x; Console.WriteLine( imie+" dostal nowy komputer!"); } else if (wybor == 2) { Mp3 New = y; Console.WriteLine(imie + " dostal nowe mp3!"); } } static void Testuj(ref Komputer x, ref Mp3 y, out int wyb, out string zmien) { wyb = 0; zmien = "TEST"; do { Console.WriteLine("Wpisz 1, aby zmieniac wartosci komputera. Wpisz 2, aby zmieniac wartosci Mp3. Wpisz 5, aby wyjsc"); wyb = int.Parse(Console.ReadLine()); switch (wyb) { case 1: do { Console.WriteLine("1. Zmiana koloru obudowy 2. Zmiana wartosci procesora 3. Zmiana wartosci pamieci karty graficznej 6. Wyjdz "); wyb = int.Parse(Console.ReadLine()); switch (wyb) { case 1: Console.WriteLine("Prosze podac nowy kolor: "); x.colour = Console.ReadLine(); break; case 2: Console.WriteLine("Prosze podac nowa wartosc double procesora"); x.processor = double.Parse(Console.ReadLine()); break; case 3: Console.WriteLine("Proszę podać nową wartość int dla pamięci karty graficznej "); x.graphic = int.Parse(Console.ReadLine()); break; } } while (wyb != 6); break; case 2: do { Console.WriteLine("1. Zmień ilość piosenek 2. Zmień ilość pamięci 7.Wyjdz "); wyb = int.Parse(Console.ReadLine()); switch (wyb) { case 1: Console.WriteLine("Prosze podać ilość nowych piosenek: "); y.songs = int.Parse(Console.ReadLine()); break; case 2: Console.WriteLine("Prosze podac nowa wartosc pamięci"); y.memory = int.Parse(Console.ReadLine()); break; } } while (wyb != 7); break; } } while (wyb != 5); } static void DokonajWyboru(out int x) { x = int.Parse(Console.ReadLine()); } static void Main(string[] args) { Komputer laptop = new Komputer(); Mp3 samsung = new Mp3(); Komputer TestLaptop = laptop; Mp3 TestMP3 = samsung; int TestWybor; string TestZmien; int wybor; do { Console.WriteLine("Witaj w menu! Wybierz urzadzennie: 1. Komputer 2.Mp3 3. Testuj 4. Prezent 9.Zakończ"); DokonajWyboru(out wybor); switch (wybor) { case 1: do { laptop.Check(); Console.WriteLine("Wybierz, co chcesz zrobic: 1.Wlacz komputer 2.Zmien 8.Wyjdz "); wybor = int.Parse(Console.ReadLine()); switch (wybor) { case 1: laptop.Start(); break; case 2: laptop.Tryb(); break; case 3: break; } } while (wybor != 8); break; case 2: do { samsung.Check(); Console.WriteLine("Wybierz, co chcesz zrobić: 1. Włącz 2. Dokup losowe piosenki 7. Wyjdz"); wybor = int.Parse(Console.ReadLine()); switch (wybor) { case 1: samsung.Start(); break; case 2: samsung.Dokup(); break; case 3: break; } } while (wybor != 7); break; case 3: Testuj(ref TestLaptop, ref TestMP3, out TestWybor, out TestZmien); Console.WriteLine("Nowe wartości komponentów testowych komputera: "); Console.WriteLine("Kolor: " + TestLaptop.colour); Console.WriteLine("Procesor: " + TestLaptop.processor); Console.WriteLine("Karta graficzna: " + TestLaptop.graphic); Console.WriteLine("Nowe wartości komponentów testowych Mp3: ");s Console.WriteLine("Ilość piosenek: " + TestMP3.songs); Console.WriteLine("Ilość pamięci: " + TestMP3.memory); Console.WriteLine("Nowa wartosc zmiennej wyboru: " + TestWybor); break; case 4: Prezent(laptop, samsung); break; } } while (wybor != 9); } } }