Answer to Question #265564 in C# for Ammar

Question #265564

Create a class that captures airline tickets. Each ticket lists the departure and arrival cities, a flight number, and a seat assignment. A seat assignment has both a row and a letter for the seat within the row (such as 12F). Make two examples of tickets?


1
Expert's answer
2021-11-13T10:47:28-0500
using System;

namespace ConsoleApp1
{
    class Program
    {
        public class AirlineTickets
        {
            public string Departure;
            public string Arrival;
            public string FlightNumber;
            public int SeatRow;
            public char SeatLetter;

            // constructor of AirlineTickets
            public AirlineTickets(string departure, string arrival, string flightNumber, int seatRow, char seatLetter)
            {
                Departure = departure;
                Arrival = arrival;
                FlightNumber = flightNumber;
                SeatRow = seatRow;
                SeatLetter = seatLetter;
            }

            // Output data about AirlineTickets to console
            public void Display()
            {
                Console.WriteLine("Airline Tickets: Departure: {0}, Arrival: {1}, FlightNumber: {2}, Seat: {3}{4}", Departure, Arrival, FlightNumber, SeatRow, SeatLetter);
            }
        }
        static void Main(string[] args)
        {
            // Make objects
            AirlineTickets ticket1 = new AirlineTickets("CDG", "FCO", "AFR28PP", 12, 'A'); ;
            AirlineTickets ticket2 = new AirlineTickets("PTY", "CDG", "AFR475", 9, 'F'); ;

            // Display data
            ticket1.Display();
            ticket2.Display();
        }
    }
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS