Introduction to Computer Science for non-majors II by James Tam Return to the course web page

CPSC 219: Mini-Assignment #1B

Due Feb 1 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)

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

Points to keep in mind:

  1. Due time: All assignments are due at 4 PM on the due dates listed on the course web page.  Late assignments or components of assignments will not be accepted for marking without approval for an extension beforehand. What you have submitted in D2L as of the due date is what will be marked.
  2. Extensions may be granted for reasonable cases by the course instructor with the receipt of the appropriate documentation (e.g., a doctor's note). Typical examples of reasonable cases for an extension include: illness or a death in the family. Cases where extensions will not be granted include situations that are typical of student life: having multiple due dates, work commitments etc. Tutorial instructors (TA's) will not be able to provide extension on their own and must receive permission from the course instructor first. (Note: Forgetting to hand your assignment or a component of your assignment in does not constitute a sufficient reason for handing your assignment late).
  3. Method of submission: You are to submit your assignment using D2L [help link]. Make sure that you [check the contents of your submitted files] (e.g., is the file okay or was it corrupted, is it the correct version etc.). It's your responsibility to do this! (Make sure that your submit your assignment with enough time before it comes due for you to do a check).
  4. Identifying information: All assignments should include contact information (full name and student ID number) at the very top of your program in the class where the 'main()' function/method resides.
  5. Collaboration: Assignments must reflect individual work, group work is not allowed in this class nor can you copy the work of others.  For more detailed information as to what constitutes academic misconduct (i.e., cheating) for this course please read the following [link].
  6. Execution: programs must run on the computer science network.  If you write you code in the lab and work remotely using a remote login program such as Putty or SSH. If you choose to install Java on your own computer then it is your responsibility to ensure that your program will run properly here. It's not recommended that you use an IDE for writing your programs but if you use one then make sure that you submit your program in the form of individual text ".java" files (one for each class that you define).
  7. Source code: in order to get any credit for your work you must submit all relevant dot-java files for the assignment (e.g., Driver.java). If you only submit your byte code files (e.g. Driver.class) then you will not be awarded any credit.

D2L configuration for this course

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().