Advertisement
ret_0

ksu_C#_2

May 27th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.98 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 поезд17._04._18
  8. {
  9.     abstract class Carriage
  10.     {
  11.         public abstract int Price();
  12.     }
  13.     class Kupe : Carriage
  14.     {
  15.         const int mestniz = 100;
  16.         const int mestverh = 10;
  17.         const int stoim = 500;
  18.         const int animal = 2000;
  19.         const int menu = 1500;
  20.         int s;
  21.         public override int Price()
  22.         {
  23.             s = (mestniz + mestverh) * (stoim + animal + menu);
  24.             return s;
  25.         }
  26.     }
  27.     class Plats : Carriage
  28.     {
  29.         const int mestniz = 54;
  30.         const int mestverh = 10;
  31.         const int stoim = 500;
  32.         const int animal = 2000;
  33.         const int menu = 1500;
  34.         int s;
  35.         public override int Price()
  36.         {
  37.             s = (mestniz + mestverh) * (stoim + animal + menu);
  38.             return s;
  39.         }
  40.     }
  41.     class SV : Carriage
  42.     {
  43.         const int mestniz = 100;
  44.         const int mestverh = 10;
  45.         const int stoim = 500;
  46.         const int animal = 2000;
  47.         const int menu = 1500;
  48.         int s;
  49.         public override int Price()
  50.         {
  51.             s = (mestniz + mestverh) * (stoim + animal + menu);
  52.             return s;
  53.         }
  54.     }
  55.  
  56.     class Train
  57.         // очень бедный поезд
  58.         // с тремя вагонами
  59.     {
  60.         Kupe ob = new Kupe();
  61.         Plats ob1 = new Plats();
  62.         SV ob2 = new SV();
  63.         int s = 0;
  64.         public int Info()
  65.         {
  66.             Console.WriteLine("Kupe " + ob.Price());
  67.             Console.WriteLine("Plats " + ob1.Price());
  68.             Console.WriteLine("SV " + ob2.Price());
  69.             s = ob.Price() + ob1.Price() + ob2.Price();
  70.             Console.WriteLine("sum " + s);
  71.             Console.ReadKey();
  72.             return 0;
  73.         }
  74.     }
  75.  
  76.     class Program
  77.     {
  78.         static void Main(string[] args)
  79.         {
  80.             Train tr = new Train();
  81.             tr.Info();
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement