Advertisement
bartigames

Samochod

Mar 4th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.85 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 ConsoleApplication1
  8. {
  9.     class marka
  10.     {
  11.      string nazwa;
  12.      public string nazwamarki()  { return nazwa; }
  13.    
  14.     public marka(string mrk)
  15.     {
  16.  
  17.         nazwa = mrk;
  18.  
  19.     }        
  20.     }    
  21.    
  22.    
  23.     class samochod : marka{
  24.         string mark;
  25.         string model;
  26.         string typ;
  27.         string vmax;
  28.         string zerosto;
  29.         int ilosc;
  30.         int cena;
  31.        
  32.         public samochod(string mrk, string mdl, string tp, string vm, string zs, int il, int cen) : base (mrk)
  33.         {
  34.  
  35.             mark = mrk;          
  36.             model = mdl;
  37.             typ = tp;
  38.             vmax = vm;
  39.             zerosto = zs;
  40.             ilosc = il;
  41.             cena = cen;
  42.  
  43.  
  44.  
  45.  
  46.         }
  47.  
  48.         public void wyswietlsamochod()
  49.         {
  50.             Console.Clear();
  51.             Console.WriteLine("-------------------------------------------------");
  52.             Console.WriteLine("{0} | {1} | {2} | {3}| {4} | {5} | {6} |", mark, model, typ, vmax, zerosto, ilosc, cena);
  53.             Console.WriteLine("-------------------------------------------------");
  54.  
  55.  
  56.         }
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.     }
  65.         class input
  66.         {
  67.             public input() {}
  68.  
  69.             public string getFromInput()
  70.             {
  71.                 string input;
  72.                 Console.Write(">:");
  73.                 input = Console.ReadLine();
  74.  
  75.                 return input;
  76.  
  77.             }
  78.  
  79.         }
  80.  
  81.  
  82.    
  83.  
  84.  
  85.  
  86.     class Program
  87.     {
  88.         static void Main(string[] args)
  89.         {
  90.            string [] danepojazdu = new string[7];
  91.            input imp = new input();
  92.            
  93.            
  94.            Console.WriteLine("Podaj markę pojazdu:");
  95.            string marka = imp.getFromInput();
  96.            marka m = new marka(marka);
  97.            danepojazdu[0] = marka;          
  98.            Console.WriteLine("wprowadź następujące dane: model, typ, vmax, 0-100, ilosc, cena; zatwierdzajac naciakając enter:");        
  99.            
  100.             for (int i = 1; i < danepojazdu.Length; i++)
  101.             {          
  102.                    
  103.              danepojazdu[i] = imp.getFromInput();
  104.  
  105.             }
  106.            samochod s = new samochod(m.nazwamarki(), danepojazdu[1], danepojazdu[2], danepojazdu[3], danepojazdu[4], Int32.Parse(danepojazdu[5]), Int32.Parse(danepojazdu[6]));
  107.  
  108.            Console.Clear();
  109.            
  110.            Console.WriteLine("Prosze wybrac opcje: \n ->wyswirtl marki \n ->wyswietl samochody");
  111.            string sw = imp.getFromInput();
  112.          //  switch (sw)
  113.         //   {
  114.        //         case
  115.  
  116.  
  117.  
  118.        //    }
  119.            
  120.             s.wyswietlsamochod();
  121.             Console.ReadLine();
  122.                
  123.             }
  124.            
  125.         }
  126.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement