Consider the following problems, design the algorithms that would solve them, and then implement the algorithm in Java. Design and implement a class called Flight that represents an airline flight.
Consider the following problems, design the algorithms that would solve them, and then implement the algorithm in Java. Design and implement a class called Flight that represents an airline flight. It should contain instance data that represents 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. Include a toString method that returns a one-line description of the flight. Create a driver class calledFlightTest, whose main method instantiates and updates several Flight objects. Define a class called Counter. An object of this class is used to count things so it records a count that is a non-negative whole number. Include methods to set the counter to 0, to increase the counter by 1, and to decrease the counter by 1. Be sure that no method allows the value of the counter to become negative. Also include an accessor method that returns the current count value, as well as a method that displays the count on the screen. Do not define an input method. The only method that can set the counter is the one that sets it to zero. Write a program to test your class definition. (nt: you need only one instance variable). Using the Die class defined in the document, , design and implement a class called PairOfDice, composed of two Die objects. Include methods to set and get the individual die values, a method to roll the dice, and a method that returns the current sum of the two die values. Create a driver class called RollingDice2 to instantiate and use a PairOfDice object. Consider a class that could be used to play a game of hangman. The class has the following attributes: It will have the following methods: Perform the following actions: Consider a class Movie that contains information about a movie. The class has the following attributes: Implement the class with accessors and mutators for the movie name and MPAA rating. Write a method addRating that takes an integer as an input parameter. The method should verify that the parameter is a number between 1 and 5, and if so, increment by one the number of people rating the movie that matches the input parameter. For example, if 3 is the input parameter, then the number of people that rated the movie as a 3 should be incremented by one. Write another method, getAverage, that returns the average value for all the movie ratings. Test the class by writing a main method that creates at least two movie objects, adds at least five ratings for each movie, and output the movie name, MPAA rating, and average rating for each movie object. All in total it should be \5 Algorithms 5 Java Programs
Do you need us to help you on this or any other assignment?
Make an Order Now