Ask Experts Questions for FREE Help !
Ask
    guthrien's Avatar
    guthrien Posts: 1, Reputation: 1
    New Member
     
    #1

    Nov 9, 2012, 09:10 PM
    Java help! Please help by tonight!
    The question is:

    B) Design and implement a class called Flight that represents an airline flight. It should contain instance data that represent the airline name, flight number, and the flight’s origin and destination cities. Define the Flight constructor to accept and initialize all instance data. Include getter and setter methods for all instance data. Have the getter methods return the data they are associated with. Include a toString method that returns a one-line description of the flight. Create a driver class called FlightTest whose main method instantiates (creates) and updates several Flight objects. Be sure to plan out what you need for this class and the driver class before you begin to code. Doing so will make your task much easier. (The account class we studied in class is a good model for this lab.)





    The code I've created so far:






    import java.util.Scanner;
    import java.text.DecimalFormat;

    public class Flight
    {

    private int id;
    private float newDestination, newOrigin;
    String flight1, flight2;
    String number1, number2;
    String origin1, origin2;
    String destination1, destination2;


    Scanner scan = new Scanner(System.in);

    public void AirlineName()
    {
    flight1 = "Delta";
    flight2 = "United";



    }

    public void FlightNumber()
    {
    number1 = "12345";
    number2 = "54321";

    }

    public void FlightOrigin()
    {
    origin1 = "Denver, Colorado";
    origin2 = "Boise, Idaho";


    }

    public void FlightDestination()
    {
    destination1 = "Miami, Florida";
    destination2 = "Las Vegas, Nevada";

    }


    public void One()
    {
    System.out.println ("This is " + flight1 + " flight " + number1 + " from " + origin1 + " to " + destination1);
    System.out.println ("This is " + flight2 + " flight " + number2 + " from " + origin2 + " to " + destination2);
    }



    }

    public void newDestination()
    {
    System.out.println ("Enter the new destination for flight 12345 " + id);
    newDestination = scan.nextFloat();
    //Billings, Montana in example below
    }

    public void Two()
    {
    System.out.println ("This is " + flight1 + " Flight " + number1 + " from " + origin1 + " to " + newDestination);

    }


    public void newOrigin()
    {
    System.out.println ("Enter the new origin for flight 54321 " + id);
    newOrigin = scan.nextFloat();
    //cheyenne, Wyoming in example below
    }

    public void Three()
    {
    System.out.println ("This is " + flight2 + " Flight " + number2 + " from " + newOrigin + " to " + destination2);

    }

    public void Four()
    {
    return id + "First Flight: This is " + flight1 + " Flight " + number1 + " from " + origin1 + " to " + newDestination;
    return id + "Second Flight: This is " + flight2 + " Flight " + number2 + " from " + newOrigin + " to " + destination2;

    }



    }

    -----------------------------------------------------------------------------------------






    public class FlightTest
    {
    public static void main (String[] args)
    {
    Flight fly1 = new Flight();
    Flight fly2 = new Flight();

    fly1.AirlineName();
    fly1.FlightNumber();
    fly1.FlightOrigin();
    fly1.FlightDestination();

    fly2.AirlineName();
    fly2.FlightNumber();
    fly2.FlightOrigin();
    fly2.FlightDestination();

    emp1.GetHeading();
    System.out.println();
    System.out.println (emp1);
    System.out.println();
    System.out.println (emp2);
    }
    }








    What the program is supposed to look like! :







    ----jGRASP exec: java FlightTest


    This is Delta Flight 12345 From Denver,Colorado to Miami,Florida
    This is United Flight 54321 From Boise,Idaho to Las Vegas,Nevada

    Enter the new destination for flight 12345
    Billings,Montana

    This is Delta Flight 12345 From Denver,Colorado to Billings,Montana

    Enter the new origin for flight 54321
    Cheyenne,Wyoming

    This is United Flight 54321 From Cheyenne,Wyoming to Las Vegas,Nevada

    First flight: This is Delta Flight 12345 From Denver,Colorado to Billings,Montana
    Second flight: This is United Flight 54321 From Cheyenne,Wyoming to Las Vegas,Nevada

    ----jGRASP wedge2: exit code for process is 0.
    ----jGRASP: operation complete.

Check out some similar questions!

I want to to eat tonight! [ 0 Answers ]

In the 1950's there was a movie on TV that I thought had William Bendix, but it seems it wasn't him. Two solders are in the pacific island with a machine gun, either a ma deuce, or a water cooled, and hundreds of Japanese solders charge them in the dark. This goes on all night, in a low fog. ...

90's R&B song titled Tonight, tonight or Tonight. [ 2 Answers ]

I am looking for a song by a group from the 90's. It has a nice slow beat. I only remember a few lyrics. I heard it on my R&b channel on my satellite but I caught the end of it.

Should I go & have a3 way tonight? [ 8 Answers ]

There's this girlfriend of mine that want's a 3 some with me & another guy, & I just hooked up with online, that sounds cool. I just don't know if I'm up to it, I mean I'm always thinking about doing it & been wanting to do it too. Don't know if I should go ahead with it. what do you think?

Seeing the Ex tonight, what is she up to ? [ 13 Answers ]

I have posted my story here on a few threads, She left me after 2 years to go back to her abusive Ex last summer, when she left me it was because she could not get stronger feelings for me, I know she tried, she was honest with me about it and I took it very hard. I treated her very good. She...

I saw my ex tonight... [ 10 Answers ]

I went to tgi fridays and it was one that was not the one me and my ex used to go to and it's a little far from his house. I was with my friends and all of sudden I saw his friends and then he walks in! My initial reaction was to flip out! I just got up and moved to the end of the table. I don't...


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.