Airline reservation system-tic tac toe-inheritance hierarchy


Question 1: (Airline Reservations System): A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You are to write an application to assign seats on each flight of the airline's only plane (capacity: 10 seats).

Your application must display the given alternatives: Please type 1 for First Class and Please type 2 for Economy. If the user types 1, your application must assign a seat in the first-class section (seats 15). If the user types 2, your application must assign a seat in the economy section (seats 610).

Use a 1-dimensional array of simple type bool to symbolize the seating chart of the plane. Initialize all the elements of the array to false to point out that all the seats are empty. As each seat is assigned, set the corresponding element of the array to True to point out that the seat is no longer available.

Your application must never assign a seat which has already been assigned. When the economy section is full, your application must ask the person if it is acceptable to be placed in the first-class section (and vice-versa). If yes, make the proper seat assignment. If no, display the message ‘Next flight leaves in 3 hours’.

Question 2: (Set of Integers): Make class IntegerSet. Each IntegerSet object can hold integers in the range 0 - 100. The set is represented by an array of bools. Array element a[i] is true if integer i is in the set. Array element a[j] is false if integer j is not in the set. The parameter less constructor initializes the array to the ‘empty set’ (that is, a set whose array representation contains all false values).

Provide the given methods:

a) Method Union makes a third set which is the set-theoretic union of two existing sets (that is, an element of the third set’s array is set to true if that element is true in either or both of the existing sets - or else, the element of the third set is set to false).

b) Method Intersection makes a third set which is the set-theoretic intersection of two existing sets (that is, an element of the third set’s array is set to false if that element is false in either or both of the existing sets - or else, the element of the third set is set to true).

c) Method InsertElement inserts a new integer k to a set (by setting a[k] to true).

d) Method DeleteElement deletes integer m (by setting a[m] to false).

e) Method ToString returns a string containing a set as a list of numbers separated by spaces. Comprise only such elements which are present in the set. Use --- to represent an empty set.

f) Method IsEqualTo finds out whether two sets are equivalent.

Write an application to test class IntegerSet. Instantiate some IntegerSet objects. Test that all your methods work suitably.

Question 3: (Tic-Tac-Toe): Make class TicTacToe which will enable you to write a complete application to play the game of Tic-Tac-Toe. The class comprises of a private 3-by-3 rectangular array of integers. The constructor must initialize the empty board to all 0s. Allow two human players. Wherever the first player moves, place a 1 in the specified square and place a 2 wherever the second player moves. Each move should be to an empty square. After each move, find out whether the game has been won and whether it’s a draw. If you feel ambitious, alter your application so that the computer makes the moves for one of the players. As well, permit the player to specify whether he or she wants to go first or second. If you feel exceptionally ambitious, develop an application which will play three-dimensional Tic-Tac-Toe on a 4-by-4-by-4 board.

Question 4: (Package Inheritance Hierarchy): Package-delivery services, like FedEx®, DHL® and UPS®, offer a number of various shipping options, each with specific costs associated. Make an inheritance hierarchy to represent different kinds of packages. UsePackage as the base class of the hierarchy, then comprise classes TwoDayPackage and OvernightPackage that derive from Package. Base class Package must comprise the name, address, city, state and zip code for the package’s sender and recipient, and instance variables that store the weight (in ounces) and cost per ounce to ship the package. Package’s constructor must initialize such private instance variables with public properties. Make sure that the weight and cost per ounce contain positive values. Package must provide a public method CalculateCost which returns a decimal pointing out the cost related with shipping the package. Package’s CalculateCost method must find out the cost by multiplying the weight by the cost per ounce. Derived class TwoDayPackage must inherit the functionality of base class Package, however as well comprises an instance variable which represents a flat fee the shipping company charges for two-day delivery service. TwoDayPackage’s constructor must receive a value to initialize this instance variable. TwoDayPackage must redefine method CalculateCost so that it calculates the shipping cost by adding the flat fee to the weight-based cost computed by base class Package’s CalculateCost method. ClassOvernightPackage must inherit directly from class Package and contain an instance variable representing an additional fee per ounce charged for overnight delivery service. OvernightPackage must redefine method CalculateCost so that it adds the additional fee per ounce to the standard cost per ounce before computing the shipping cost. Write a test application which makes objects of each kind of Package and tests method CalculateCost.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Airline reservation system-tic tac toe-inheritance hierarchy
Reference No:- TGS01962

Expected delivery within 24 Hours