Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
Question
Book Icon
Chapter 8, Problem 28E
Program Plan Intro

Program plan:

  • Import all required data packages.
  • Define player.java class.
  • Declare all required variables.
  • Create a class constructor.
  • Define getName() method.
  • Declare the getCurrentRoom() method, to get the current room number.
  • Declare the setCurrentRoom() method, to set the current room number.
  • Declare the Room.java class.
  • Declare the Game.java class:
  • Define play() method.
  • Use while loop, to iterate through all the available data values.
  • Define the printWelcome() method.
  • Define the getCommand() method.
  • Define the processCommand() method.

Program Description:

The main purpose of this question is to implement a Player class with the object that stores the current room for the player, and can also be able to store, other required information if required.

Blurred answer
Students have asked these similar questions
Dice Rolling Class In this problem, you will need to create a program that simulates rolling dice. To start this project, you will first need to define the properties and behaviors of a single die that can be reused multiple times in your future code. This will be done by creating a Dice class. Create a Dice class that contains the following members: Two private integer variables to store the minimum and maximum roll possible. Two constructors that initialize the data members that store the min/max possible values of rolls. a constructor with default min/max values. a constructor that takes 2 input arguments corresponding to the min and max roll values Create a roll() function that returns a random number that is uniformly distributed between the minimum and maximum possible roll values. Create a small test program that asks the user to give a minValue and maxValue for a die, construct a single object of the Dice class with the constructor that initializes the min and max…
Rectangle Object Monitoring Create a Rectangle class that can compute the total area of all the created rectangle objects using static fields (variables).  Remember that a Rectangle has two attributes: Length and Width.  Implement the class by creating a computer program that will ask the user about three rectangle dimensions.  The program should be able to display the total area of the three rectangle objects.  For this exercise, you are required to apply all OOP concepts that you learned in class.   Sample output: Enter Length R1:  1 Enter Width  R1:  1 Enter Length R2:  2 Enter Width  R2:  2 Enter Length R3:  3 Enter Width  R3:  3 The total area of the rectangles is 14.00   Note:  All characters in boldface are user inputs.
Cargo Ships This question involves cargo ships that carry a specific number of cargo containers. Each ship has a maximum number of cargo containers that it can hold and a current number of cargo containers that it is holding. You can see more details in the Ship class that is provided for you. Part A For part A, you will be completing the nextToUnload() method. This takes no input and returns a Ship from the ships instance variable that has the highest percentage of its cargo hold filled (as measured by current hold / capacity). If two ships have the same percentage, then it should return the first ship with that percentage. If all of the ships in the ships array are empty (ie. no cargo), the method should return null. Part B For part B, you will complete the two unloadShip methods. The first method takes a Ship object and unloads all of the cargo from that ship. The second method takes a Ship and an int and unloads the specified number of containers from the ship. If the number of…
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education