Advertisement
Patys09

Zadania programowanie

Apr 4th, 2020
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.43 KB | None | 0 0
  1. ZADANIA DO ODDANIA
  2.  
  3. 3.2
  4.  
  5.  
  6. using System;
  7. using System.Linq;
  8.  
  9.  
  10. namespace cwiczenia_lol
  11. {
  12.    
  13.     public class Zajęcia
  14.     {
  15.         public enum Typ {wykład, ćwiczenia, laboratorium, lektorat};
  16.  
  17.         public Typ Rodzaj;
  18.  
  19.  
  20.         public string nazwa;
  21.         public int czas_trwania, punkty_ects;
  22.         public Zajęcia (string Nazwa, Typ typ, int Czas_trwania, int Punty_ects)
  23.         {
  24.             nazwa = Nazwa;
  25.             Rodzaj = typ;
  26.             czas_trwania = Czas_trwania;
  27.             punkty_ects = Punty_ects;
  28.  
  29.         }
  30.  
  31.         public int Czas_trwania
  32.         {
  33.             get { return czas_trwania; }
  34.             set
  35.             {
  36.                 if(value == 15 || value == 30 || value == 45)
  37.                 {
  38.                     czas_trwania = value;
  39.                 }
  40.             }
  41.         }
  42.  
  43.         public int Punkty_ects
  44.         {
  45.             get { return punkty_ects; }
  46.             set
  47.             {
  48.                 if((value > 0) && (value < 7))
  49.                 {
  50.                     punkty_ects = value;
  51.                 }
  52.             }
  53.         }
  54.  
  55.  
  56.     }
  57.  
  58.     class Program
  59.     {
  60.  
  61.         static void Main(string[] args)
  62.         {
  63.             Zajęcia programowanie_cwiczenia = new Zajęcia("Programowanie komputerów", Zajęcia.Typ.ćwiczenia, 45, 6);
  64.             Zajęcia programowanie_wyklad = new Zajęcia("Programowanie komputerów", Zajęcia.Typ.wykład, 45, 6);
  65.  
  66.  
  67.         }
  68.     }
  69. }
  70.  
  71.  
  72. ------------------------------------------------------------------
  73.  
  74. 3.1
  75.  
  76. using System;
  77. using System.Linq;
  78.  
  79.  
  80. namespace cwiczenia_lol
  81. {
  82.  
  83.     public enum Kolory { karo = 40, kier = 60, pik = 80, trefl = 100 };
  84.     public enum Wartości
  85.     {
  86.         AS = 1,
  87.         Dwójka = 2,
  88.         Trójka = 3,
  89.         Czwóra = 4,
  90.         Piątka = 5,
  91.         Szóstka = 6,
  92.         Siódemka = 7,
  93.         Ósemka = 8,
  94.         Dziewiątka = 9,
  95.         Dziesiątka = 10,
  96.         Jupek = 10,
  97.         Dama = 10,
  98.         Król = 10
  99.     };
  100.  
  101.     class Karty
  102.     {
  103.         public Kolory kolory;
  104.         public Wartości wartości;
  105.  
  106.         public string wartość;
  107.         public string kolor;
  108.  
  109.         public Karty(Kolory _kolory, Wartości _watosci)
  110.         {
  111.             kolory = _kolory;
  112.             wartości = _watosci;
  113.         }
  114.  
  115.         public string Wartość
  116.         {
  117.             get { return wartość; }
  118.             private set { wartość = value; }
  119.         }
  120.  
  121.         public void OpiszKarte()
  122.         {
  123.             Console.WriteLine($"{kolory} {wartości}");
  124.         }
  125.  
  126.         class Program
  127.         {
  128.  
  129.             static void Main(string[] args)
  130.             {
  131.                 Karty karta = new Karty(Kolory.karo, Wartości.Dwójka);
  132.                 karta.OpiszKarte();
  133.             }
  134.         }
  135.     }
  136. }
  137.  
  138. ---------------------------------------------------------------------------
  139.  
  140. 3.3
  141.  
  142.     using System;
  143.  
  144. namespace cwiczenia_lol
  145. {
  146.  
  147.     struct Pies
  148.     {
  149.         public string rasa;
  150.         public int wiek;
  151.  
  152.         public void Wyswietl()
  153.         {
  154.             Console.WriteLine($"Rasa psa : {rasa}, wiek psa: {wiek}");
  155.         }
  156.  
  157.     }
  158.     class Program
  159.     {
  160.  
  161.         static void Main(string[] args)
  162.         {
  163.  
  164.             Pies reksio;
  165.             reksio.rasa = "golden retriever";
  166.             reksio.wiek = 3;
  167.  
  168.             Pies burek = reksio;
  169.             reksio.Wyswietl();
  170.             burek.Wyswietl();
  171.  
  172.         }
  173.     }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement