Advertisement
Guest User

Untitled

a guest
Jul 6th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void nadajSpecyfikacje(Komputer komp1)
  12.         {
  13.             Console.Write("Podaj nazwe komputera: ");
  14.             komp1.nazwa = Console.ReadLine();
  15.             Console.Write("Podaj procesor komputera: ");
  16.             komp1.procesor = Console.ReadLine();
  17.             Console.Write("Podaj karte graficzną komputera: ");
  18.             komp1.kartaGraficzna = Console.ReadLine();
  19.         }
  20.         static void pokazSpecyfikacje(Komputer komp1)
  21.         {
  22.             Console.Write("Nazwa komputera: "); Console.WriteLine(komp1.nazwa);
  23.             Console.Write("Procesor: "); Console.WriteLine(komp1.procesor);
  24.             Console.Write("Karta graficzna: "); Console.WriteLine(komp1.kartaGraficzna);
  25.         }
  26.         static void Main(string[] args)
  27.         {
  28.             int koniec = 0;
  29.             do
  30.             {
  31.                 Console.WriteLine("Witaj w menu głównym!");
  32.                 Console.WriteLine("[1] Nowy komputer");
  33.                 Console.WriteLine("[2] Pokaż specyfikacje");
  34.                 Console.WriteLine("[3] Wyjdź z programu");
  35.                 int warunek = int.Parse(Console.ReadLine());
  36.                 switch (warunek)
  37.                 {
  38.                     case 1:
  39.                         {
  40.                             Komputer komp1 = new Komputer();
  41.                             nadajSpecyfikacje(komp1);
  42.                             break;
  43.                         }
  44.                     case 2:
  45.                         {
  46.                             pokazSpecyfikacje(komp1);
  47.                             break;
  48.                         }
  49.                     case 3:
  50.                         {
  51.                             koniec = 1; // spelnony warunek wyjscia
  52.                             break;
  53.                         }
  54.                     default:
  55.                         {
  56.                             Console.WriteLine("Podano złą wartość");
  57.                             koniec = 1;
  58.                             break;
  59.                         }
  60.                 }
  61.             } while (koniec != 1);
  62.         }
  63.     }
  64.     class Komputer
  65.     {
  66.         public string nazwa;
  67.         public string procesor;
  68.         public string kartaGraficzna;
  69.         public void startKomputera()
  70.         {
  71.             Console.WriteLine("Komputer jest uruchamiany");
  72.         }
  73.         public void wylaczanieKomputera()
  74.         {
  75.             Console.WriteLine("Komputer jest wyłączany");
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement