Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace поезд17._04._18
- {
- abstract class Carriage
- {
- public abstract int Price();
- }
- class Kupe : Carriage
- {
- const int mestniz = 100;
- const int mestverh = 10;
- const int stoim = 500;
- const int animal = 2000;
- const int menu = 1500;
- int s;
- public override int Price()
- {
- s = (mestniz + mestverh) * (stoim + animal + menu);
- return s;
- }
- }
- class Plats : Carriage
- {
- const int mestniz = 54;
- const int mestverh = 10;
- const int stoim = 500;
- const int animal = 2000;
- const int menu = 1500;
- int s;
- public override int Price()
- {
- s = (mestniz + mestverh) * (stoim + animal + menu);
- return s;
- }
- }
- class SV : Carriage
- {
- const int mestniz = 100;
- const int mestverh = 10;
- const int stoim = 500;
- const int animal = 2000;
- const int menu = 1500;
- int s;
- public override int Price()
- {
- s = (mestniz + mestverh) * (stoim + animal + menu);
- return s;
- }
- }
- class Train
- // очень бедный поезд
- // с тремя вагонами
- {
- Kupe ob = new Kupe();
- Plats ob1 = new Plats();
- SV ob2 = new SV();
- int s = 0;
- public int Info()
- {
- Console.WriteLine("Kupe " + ob.Price());
- Console.WriteLine("Plats " + ob1.Price());
- Console.WriteLine("SV " + ob2.Price());
- s = ob.Price() + ob1.Price() + ob2.Price();
- Console.WriteLine("sum " + s);
- Console.ReadKey();
- return 0;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Train tr = new Train();
- tr.Info();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement