Advertisement
bartigames

Untitled

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