Informatică, întrebare adresată de andreistancu96, 7 ani în urmă

Salut ! Ma puteti ajuta si pe mine va rog la acesta problema ? lucrez la sololearn c# si am intampinat aceasta problema ,nu ii dau de cap
Derived Class Constructor & Destructor


You are the airport administrator responsible for setting flight statuses.
At first the flight program was showing only "Registration" and "Closed" statuses, but we need to expand it to give more detailed information.
Derive WayStatus class from Flight class and complete its
1. constructor, to output "On the way"
2. destructor, to output "Landed"

so that the program correctly outputs all the statuses of the flight.

Anexe:

Răspunsuri la întrebare

Răspuns de danielpetrupasc
0

Răspuns:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading;

using System.Threading.Tasks;

namespace SoloLearn

{

   class Program

   {

       static void Main(string[] args)

       {

           WayStatus status = new WayStatus();

       }

   }

   class Flight

   {

       public Flight()

       {

           Console.WriteLine("Registration");

       }

       ~Flight()

       {

           Console.WriteLine("Closed");

       }

   }

   /*derive this class from Flight class,

   define constructor and destructor for it*/

   class WayStatus : Flight

   {

       

   }

}

În acest cod, am adăugat linia de cod necesară pentru a indica faptul că clasa WayStatus este derivată din clasa Flight, astfel încât să poată folosi constructorul şi destructorul acesteia. Acest lucru va permite programului să funcţioneze corect.

Explicație:

Sper să te ajute.

Alte întrebări interesante