Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Створити абстрактний клас «літак» і похідні від нього «винищувач» та
- «пасажирський лайнер». Функції введення та виведення даних в базовому класі
- зробити абстрактними і визначити їх конкретно в похідних класах.
- Продемонструвати їхню роботу.
- */
- /*
- * Created by SharpDevelop.
- * User: vladyslavbezruk
- * Date: 08.04.2022
- * Time: 23:21
- *
- * To change this template use Tools | Options | Coding | Edit Standard Headers.
- */
- using System;
- namespace lab_1
- {
- abstract class Plane
- {
- protected double max_speed;
- protected Plane()
- {
- max_speed = 0;
- }
- public abstract void input();
- public abstract void output();
- }
- class Fighter_aircraft : Plane
- {
- private double rockets_count;
- public Fighter_aircraft() : base()
- {
- rockets_count = 0;
- }
- public override void input()
- {
- Console.WriteLine("Enter info about fighter aircraft:");
- Console.WriteLine("max speed:");
- max_speed = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("rockets count:");
- rockets_count = Convert.ToDouble(Console.ReadLine());
- Console.Write("\n");
- }
- public override void output()
- {
- Console.WriteLine("Info about fighter aircraft:");
- Console.WriteLine("max speed: {0}", max_speed);
- Console.WriteLine("rockets count: {0}", rockets_count);
- Console.Write("\n");
- }
- }
- class Passenger_liner : Plane
- {
- private int passengers_count;
- public Passenger_liner() : base()
- {
- passengers_count = 0;
- }
- public override void input()
- {
- Console.WriteLine("Enter info about passenger liner:");
- Console.WriteLine("max speed:");
- max_speed = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("passengers count:");
- passengers_count = Convert.ToInt32(Console.ReadLine());
- Console.Write("\n");
- }
- public override void output()
- {
- Console.WriteLine("Info about passenger liner:");
- Console.WriteLine("max speed: {0}", max_speed);
- Console.WriteLine("passengers count: {0}", passengers_count);
- Console.Write("\n");
- }
- }
- class Program
- {
- public static void Main(string[] args)
- {
- Plane fighter_aircraft = new Fighter_aircraft();
- Plane passenger_liner = new Passenger_liner();
- fighter_aircraft.input();
- fighter_aircraft.output();
- passenger_liner.input();
- passenger_liner.output();
- // TODO: Implement Functionality Here
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment