Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

a. Write code to define an abstract class 'Passenger" with the following attributes: account_num, fname, lname, points, num_pass (NB this is a class variable which keeps a tally on the number of passenger objects created)
There is only one constructor that receives: account_num, fname, lname, points. You must also include the necessary 'getters' and 'setters' (where appropriate) to make the attributes available. Include an abstract method 'calcPoints' that returns nothing but accepts the cost of the ticket.

b. Write a method 'toString' for the Passenger object defined above. This method must return a string stating the: account_num, fname, lname, points of the Passenger in a well structured sentence/format.

c. Define a separate class 'Regular' which is a subclass of 'Passenger'. In the constructor of this new class ensure that you invoke the constructor of the parent class 'Passenger' to initialize the inherited variables. Implement the 'calcPoints' method as follows:
1. Finds the current points by dividing the ticket cost by 10 e.g. $1500 / 10 = 150 points
2. Adds the current points to the points already accumulated
[4 marks]

d. Define a separate class 'Premium' which is a subclass of 'Passenger'. In the constructor of this new class ensure that you invoke the constructor of the parent class 'Passenger' to initialize the inherited variables. Implement the 'calcPoints' method as follows:
1. Finds the current points by dividing the ticket cost by 5 e.g $1500 / 5 = 300 points
2. Adds the current points to the points already accumulated


e. Write a separate class 'Airline' which contains a main method. In the main method you must create four objects: two Regular Passenger and two Premium Passenger. Next you are required to create an array 'pass_arr' of type 'Passenger'of size 4. Store the four account objects in this array. Finally you are required to perform the following operations on the objects:
i. Traverse the array and display the information for each Passenger by invoking the 'toString()' method you wrote in part b.
ii. Traverse the array and invoke 'calcPoints' for each Passenger to update the points earned thus far.
iii. Output the updated array.

NB. To create the 'Regular' and 'Premium' Passenger objects above you are free to 'hard code' the attribute values.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91229343
  • Price:- $60

Guranteed 36 Hours Delivery, In Price:- $60

Have any Question?


Related Questions in Computer Engineering

Quality management plan it should includea short statement

Quality Management Plan. It should include: A short statement that reflects your team's philosophy or objective for ensuring that you deliver a quality system to your client. Develop and describe the following that your ...

Two manufacturing firms are located on the banks of the

Two manufacturing firms are located on the banks of the Crimea River. Riditna Paper withdraws river water for use in its paper mill, and returns it, along with waste effluent, back into the river. (Effluent is a co-produ ...

Answer the following questions 1 suppose we want to

Answer the following Questions : 1. Suppose we want to transmit the message 1011101110 and protect it from using the CRC polynomial x 3 + x + 1. Use polynomial long division to determine the message should be transmitted ...

Are search algorithms tied to data structures being

Are search algorithms tied to data structures being searched, or can they be utilized in other scenarios?

When a 5606g sample of walnuts is burned with excess oxygen

When a 56.06g sample of walnuts is burned with excess oxygen in a bomb calorimeter with a heat capacity of 23.25kJK-1. The temperature of the calorimeter rises fro 17.78C to 94.57C. What is the (Delta)U(rxn) value, in un ...

Question in the link below it has all the information that

Question: In the link below it has all the information that needs to be in the crowsfoot erd. Don't take on this assignment if you cant put all the info in the ERD. The instructor will grade the work that you do and send ...

Tasks1 identify possible actors and use cases involved in

Tasks: 1. Identify possible actors and use cases involved in Personal Trainer's operations. 2. Create an object relationship diagram for the Personal Trainer information system. 3. Create a use case diagram for the syste ...

Ellen is an anthropologist who has been working at olduvai

Ellen is an anthropologist who has been working at Olduvai Gorge in Tanzania for the past six months. She has been conducting research on the Internet. She finds a Web site with an article that proposes a revolutionary t ...

Can someone help me identify how intrustion detection

Can someone help me identify how Intrustion detection system and intrusion prevent system can help protect confidentiality, integrity and availability

An article in the wall street journal noted that an

An article in The Wall Street Journal noted that an" increase in the price of crude oil quickly reduces demand for oil". Do you agree with this statement? Briefly explain.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As