Allan Didier

Game Character

Goals

Students will demonstrate their understanding of object instantiation, class creation and the use of constructor, accessor, and mutator methods in Java by creating a game character program following the details below and the programming rubric. 

Skills

  • Object oriented programming
  • Class creation
  • Object instantiation

Program Details

 Create a program that can create, access and modify game characters from a game character class.

  1. Game Character Class
    1. 3 private Data Variables
      1. String Name
      2. String Attribute (class, position, address, etc.)
      3. Integer Statistic (health, intelligence, age, grade, etc.)
    2. Methods
      1. Constructor method
        1. Passes in all three values as parameters.
        2. Sets the values for the Name, Attribute, and Statistic.
      2. Three Accessor methods (getters)
        1. Must be declared Public.
        2. One for each of the above data variables.
        3. Pass in no parameters.
        4. Return the appropriate variable.
      3. Four Mutator methods (setters)
        1. Sets the Name on the character
          1. Must be declared public void.
          2. Passes in the new name as the parameter.
        2. Sets the Attribute of the character.
          1. Must be declared public void.
          2. Passes in the new Attribute
        3. Sets the Statistic
          1. Must be declared Public void.
          2. Passes in the new Statistic value.
          3. Sets the Statistic to the new value.
          4. Value must be a positive value.
        4. Change Statistic
          1. Must be declared Public void.
          2. Passes in an integer value to change the Statistic by.
          3. Increments or decrements the Statistic by the value.
          4. Checks to see if the statistic is beyond a threshold value and will report if it is. For example: if the character’s health drops below zero, the program should report that the character has died.
  2. Main Program Class:
    1. Object Instantiation
      1. Create at least 2 objects (characters) from the above class.
      2. Use the constructor method to create the objects.
      3. Enter the data directly in your program. You don’t need to ask the user to input the data.
    2. Object modification
      1. Change the Name, Attribute, and Statistic of one object using the Setter methods.
      2. Call the Change Statistic method twice
      3. Increment or decrement one character’s Statistic, but not outside of the threshold
      4. Increment or decrement the other character’s Statistic to a value outside of the threshold limit. This should trigger an output from the Change Statistic method.
      5. Enter the data directly in your program. You don’t need to ask the user to input the data.
    3. Output
      1. Output the following information to the console:
        1. The initial values of both characters
        2. The changes that were made to each character
        3. The final values of both characters
        4. Your Change Statistic from above should output when the character Statistic is modified too much. Your main program does not need to do this directly.
      2. Use the Getter methods to output the data.

Resources

Java Textbook

Chapter 4: Writing Classes

Chapter 7: Object Oriented Design

CS Awesome Website

Bill Barnum's AP Computer Science A videos

AP College Board test prep videos