zed_com

pract9

Nov 11th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.09 KB | None | 0 0
  1. using System;
  2.  
  3. namespace C
  4. {
  5.     class Program
  6.     {
  7.         abstract class Plane
  8.         {
  9.             protected string brand;
  10.             protected double speed;
  11.             public abstract void input();
  12.             public abstract void output();
  13.         }
  14.         class Destroyer : Plane
  15.         {
  16.             string status;
  17.             public override void input()
  18.             {
  19.                 Console.Write("Модель истребителя:");
  20.                 brand = Console.ReadLine();
  21.                 Console.Write("Его сокрость:");
  22.                 speed = Convert.ToDouble(Console.ReadLine());
  23.                 Console.Write("В каком состоянии:");
  24.                 status = Console.ReadLine();
  25.             }
  26.             public override void output()
  27.             {
  28.                 Console.Write("Модель:{0}\nСкорость:{1} км/ч\nСостояние:{2}\n", brand, speed, status);
  29.             }
  30.         }
  31.         class Passenger_liner : Plane
  32.         {
  33.             int count_people;
  34.             public override void input()
  35.             {
  36.                 Console.Write("Модель пассажирского транспорта:");
  37.                 brand = Console.ReadLine();
  38.                 Console.Write("Скорость транспорта:");
  39.                 speed = Convert.ToDouble(Console.ReadLine());
  40.                 Console.Write("Сколько пассажиров может поместиться:");
  41.                 count_people = Convert.ToInt32(Console.ReadLine());
  42.             }
  43.             public override void output()
  44.             {
  45.                 Console.Write("Марка:{0}\nСкорость:{1} км/ч\nМаксимальное количество людей:{2} кол\n", brand, speed, count_people);
  46.             }
  47.         }
  48.         static void Main(string[] args)
  49.         {
  50.             Plane d = new Destroyer();
  51.             d.input();
  52.             d.output();
  53.             d = new Passenger_liner();
  54.             d.input();
  55.             d.output();
  56.             Console.ReadKey();
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment