Define the flight constructor to accept all instance data

Assignment Help Other Subject
Reference no: EM132586509

Assignment: Consider the following problems, design the algorithms that would solve them, and then implement the algorithm in Java.

Problem 1: 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.

Problem 2: 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. (Hint: you need only one instance variable).

Problem 3: Using the Die class defined in the document, Die.java, 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.

Problem 4: Consider a class that could be used to play a game of hangman. The class has the following attributes:

• The secret word

• The disguised word, in which each unknown letter in the secret word is replaced with a question mark (?). For example, if the secret word is abracadabra, and the letters a , and b have been guessed, the disguised word would be ab?a?a?ab?a

• The number of guesses made

• The number of incorrect guesses

It will have the following methods:

• MakeGuess(c) guesses that character c is in the word

• getDisguisedWord returns a string containing correctly guessed letters in their correct positions and unknown letters replaced with ?

• getSecretWord returns the secret word

• getGuessCount returns the number of guesses made

• isFound returns true if the hidden word has been discovered.

Perform the following actions:

• Write a method heading for each method.

• Write preconditions and postconditions for each method.

• Write some Java statements that test the class.

• Implement the class.

• List any additional methods and attributes needed in the implementation that were not listed in the original design. List any other changes made to the original design.

• Write a program that implements the game of handgman, using the class you wrote for part d.

Problem 5: Consider a class Movie that contains information about a movie. The class has the following attributes:

• The movie name

• The MPAA rating (e.g. G, PG, PG-13, R)

• The number of people that have rated this movie as a 1 (Terrible)

• The number of people that have rated this movie as a 2 (Bad)

• The number of people that have rated this movie as a 3 (OK)

• The number of people that have rated this movie as a 4 (Good)

• The number of people that have rated this movie as a 5 (Great)

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.

Reference no: EM132586509

Questions Cloud

How might anthropologists use the content you have chosen : In analyze I would like you to write more extensively about your chosen medium: why did you choose it? Did our coursework help you better understand.
How does hiv replicate : How does HIV replicate? What kind of virus is it?
Global market-international manufacturing organization : Describe the steps you would take in evaluating the decisions to be made in this situation. Explain your reasoning for the type of decision making you selected.
Cocktail therapy to cure the hiv disease : It takes 60-60 years of cocktail therapy to cure the HIV disease. Why?
Define the flight constructor to accept all instance data : Design and implement a class called Flight that represents an airline flight. It should contain instance data that represents the airline name, flight number.
What date should the company decrease working capital : Another 10,000 shares were repurchased on April 25, Year One. On what date should the company decrease its working capital as a result of this dividend ?
Assignment - DNA replication Thought Questions : Assignment - DNA replication Thought Questions. If you draw one replication bubble, how many replication forks have you drawn
The human resource development positions : Discuss why those in the human resource development positions are in a prime position to facilitate the change process.
Prepare all of the journal entries for the lessee : Prepare all of the journal entries for the lessee for 2020 and 2021 to record the lease agreement, the lease payments, and all expenses

Reviews

Write a Review

Other Subject Questions & Answers

  Home sales tend to increase over time under normal condition

Home sales tend to increase over time under normal conditions, but the recession of 2008 and 2009 has reportedly caused the resale price of existing homes to fall nationwide. You would like to see if the data support this conclusion. the file HomePri..

  Which holds greater potential to slow global climate change

Compare the carbon reducing potential of the two plans and analyze which holds the greater potential to slow global climate change and why.

  Analyzing a communication technique-presentations

Analyzing a communication technique-presentations. On a daily basis, it is often expected that professionals be proficient with presentations.

  How do different philosophies of policing impact

How do different philosophies of policing impact the response to drugs in our society?

  Define computer crime including the categories of offenses

Describe the public perception of an organized crime entity in America. List the features commonly associated with syndicated crime. Define computer crime, including the categories of offenses. How do organizations create opportunities for illegal c..

  What research tools are available for you to use

What research tools are available for you to use? Make a list and check their avail- ability. Determine how you will use them.

  What alterations would you suggest in his treatment

What alterations would you suggest in his treatment? Be sure to consider additional diagnoses and whether prophylaxis would be appropriate for NSAID-induced ulcers

  How broad or detailed should that knowledge be

How much technological knowledge should security professionals have? How broad or detailed should that knowledge be?

  Calculate the flow rate through a linear control valve

Calculate the flow rate through a linear control valve with a Cv, max equal to 83.3 that has a valve position of 75% open when the pressure drop across the valve is 55psi. Assume that the liquid flowing through the control valve has a density to 55 l..

  What are the processes for approval of new programs

Describe the organizational structure of the parent academic institution (your selected college or university). What are the processes for approval.

  Compared with clients using other types of therapies

Do you think that clients who succeed when using third generation therapies are better off in the long run as compared with clients using other types of therapies? Why or why not?

  Discuss the connection between socioeconomic status-race

Discuss the connection between socioeconomic status, race, ethnicity, and the educational system. Use examples from the video the justify your answer.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd