ASU CSE 110 Assignment #4 Due date Time: Friday, March 3rd, 2017 at 5:30pm What
ID: 3861632 • Letter: A
Question
ASU CSE 110 Assignment #4 Due date Time: Friday, March 3rd, 2017 at 5:30pm What this Assignment Is About Given a UML diagram, learn to design a class. Team how to define constnictor, accessor, mutator and toString( methods, etc. Learu how to create au object and wall an in ruethod. Coding Guidelines for All Labs/Assignments You will be graded on this Give identifiers semantic meaning and make them easy to read (example numSndents, grossPay, etc). Keep identifiers lo a reasonably sbort length. Use upper case for constants. Use title case (first letter is u case) for classes. Use lower case with uppercase word separators for all other identifiers variables, methods. objects). Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with its. switches and loops. Be consistent with the number of spaces or tabs that you use to ndent Use white space to make your progra more readable Use comments properly before or after the ending brace of classes, methods, and blocks to identify to which block it belongs Assignment description 1. Step According to the follo ing UML diagrau, desigu a Flight class, save the souce vode as Flight java Flight irLL ept City String ur icily: uring price: double t light int, String String double) get Flight Num int +get Dept City String getArricity String +get price donible elFlighuNuur (inL) void. etnept.City tring) void +selArricily SLring void raise Price (double) void +reduct Fri Kdouble) voidExplanation / Answer
Hello Student,
I have implemented the Assignment Four Class, The code is very straight forward.
Replace yourpackage with the actual package path of Flight Class, rest is easy.
Please find the Source Code :- http://pastebin.com/rY5CiWK3
For Your convenience I am also pasting code here :-
import java.lang.*;
//Replace your Package with the pacakge name
import yourpackage.Flight;
public class AssignmentFour{
Flight flight;
private int flightNumber
private String departureCity, arrivalCity;
private double newPrice;
private char choice;
double rate;
Scanner in = new Scanner(System.in);
public void getFlightInfo()
{
System.out.println("Enter Flight Number");
this.flightNumber = in.nextInt();
System.out.println("Enter Arrival City");
this.arrivalCity = in.nextLine();
System.out.println("Enter Departure City");
this.departureCity = in.nextLine();
System.out.println("Enter Price");
this.newPrice = in.nextDouble();
}
public void DisplayMenu()
{
System.out.println("Choose an Action. Enter the key following your choice");
Sytem.out.println("Enter 'D' to Change Departure City");
Sytem.out.println("Enter 'A' to Change Arrival City");
Sytem.out.println("Enter 'I' to Increase the price");
Sytem.out.println("Enter 'R' to Reduce the price");
Sytem.out.println("Enter 'S' to Show Fligh Info");
Sytem.out.println("Enter '?' to Display the Menu");
Sytem.out.println("Enter 'Q' to Exit Program");
}
public void getChoice()
{
DisplayMenu();
this.choice = in.next().trim().charAt(0);
}
public static void main(String[] args)
{
getFlightInfo();
flight = new Flight(this.flightNumber, this.departureCity, this.arrivalCity, this.newPrice );
getChoice();
while (this.choice.lower() != 'q')
{
switch(this.choice.upper())
{
Case 'D' :
this.departureCity = in.nextLine().trim();
flight.setDeptCity(this.departureCity);
break;
Case 'A' :
this.arrivalCity = in.nextLine().trim();
flight.setArriCity(this.arrivalCity);
break;
Case 'I' :
rate = in.nextDouble();
flight.raisePrice(rate);
break;
Case 'R' :
rate = in.nextDouble();
flight.reducePrice(rate);
break;
Case '?' :
getChoice();
break;
Case 'S' :
flight.toString();
break;
Case 'Q':
break;
}
}
}
}