Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Object Oriented in Java

dickersonka
dickersonka 


1. Write a program in Java to allow a user select a seat on the passenger airjet. The program should have the following structure: a) Object A should provide the list of seats and their pricing to the user. b) Object B should allow the user to choose a seat from the list of available seats. c) Object C should display the total cost of the seat choosen by the user. 2. Modify the above program to use an interface having variables that will be used to determine the pricing on every seat available on the airjet. 3. Modify the program written for question 2 to implement inheritance in providing the list of available seats to the user. 4. Using a snippet explain how common coupling can be avoided in writing this program. 5. Using a snippet explain how utility cohesion can be implemented in writing this program. Attachments Tags Clarifications

Answers

Java - Plane Seating

dickersonka
dickersonka 



Attached is the solution including source, comments, and answers to the questions. The instructions were quite vague, but I believe the goal of the assignment was accomplished. Let me know if you have any questions. Attachments
Plane.zip (3 K) Download
Preview
was factored into the base class. Since the base class contained the pricing for the aisle seat and knew nothing about first class, when the first class seat needed pricing information it could expand upon

Preview
seat.getPrice()); } //prompt user for choice System.out.print("Which seat would you like (1-5): "); int choice = input.nextInt(); //get seat Seat seat = seats[choice - 1]; //display total System.out.println("The seat price is: $" + seat.getPrice()); } class Seat{

Preview
seats for(int i=0; i<seats.length; i++){ //display pricing for each seat Seat seat = seats[i]; System.out.println("[" + (i + 1) + "] - " + seat.getDescription() + ", Price = " + seat.getPrice()); } //prompt user for choice System.out.print("Which seat would you like

Preview
seats = new Seat[5]; seats[0] = new FirstClassSeat("First Class - Aisle 1A", true); seats[1] = new FirstClassSeat("First Class - Window 1W", false); seats[2] = new Seat("Coach - Aisle 6A", true); seats[3] = new Seat("Coach - Window 6W", false); seats[4] = new Seat("Coach - Window 7W",

Screenshots
Purchase Answer