Course web page: Introduction to Computer Science for majors II James Tam Return to the course web page

CPSC 233: Mini-Assignment #2

Due Sept 25 at 4 PM

New Concepts to be applied for the assignment

Description

Your program must consist of two classes (as described below). Aside from the 'main()' method you are not to write static methods for this assignment. (If you don't know what I'm referring to by static methods, I will be discussing this topic later in the course). If you do implement other static methods then you will receive few, if any, marks for features listed below. Also to make it easier to mark ensure that your method carries out the prescribed tasks exactly as specified (so the the person knows precisely what results should come out at what times).

Details

  • Defines a class 'Adventurer' (6 marks)
 
  •  Attributes: name (String), and health (int) (2 marks)
 
  • Methods:
     
  • A no argument constructor that sets the name and health attributes to obvious default starting values (e.g., "nameless" for the name and -1 for the health (2 marks)
  • A 'gainLevel()' method that displays a message onscreen ("Congratulations!") and increases health by 5. (2 marks)
     
  • Defines the 'Driver' class. The 'main()' method will contain the following instructions (8 marks)
 
  • Declares a reference to an 'Adventurer' (1 mark)
  • Creates an  'Adventurer' object by calling the default constructor (1 mark)
  • Displays the health and name of the adventurer, the default values should appear (2 marks)
  • Uses the mutator methods to set the name to 'Balin' and health to 10 (2 marks)
  • Calls the 'gainLevel()' method of the adventurer (1 mark)
  • Displays the health and name of the adventurer, the new values should appear 'Balin' and 15 (1 mark)

Submitting your work:

  1. Assignments (source code/'dot-java' file) must be electronically submitted according to [the assignment submission requirements] using [D2L].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].

Marking key

Marks earned 14 13 12 11 10 9 8 7 6 5 4 3 2 - 0
Grade point 4.0 3.7 3.3 3 2.7 2.3 2 1.7 1.3 1.0 0.7 0.5 0.0

External libraries that can be used (unless otherwise you can not assume that you can use the library).

  1. You cannot use methods other than the ones for output: printf(), print(), println().