Back to the faculty page for James Tam Return to the course web page

CPSC 233: Mini-Assignment 1b

Due at 4 PM. For assignment due dates see the main grid on the course webpage.

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. To make it easier to mark ensure that your method carries out the prescribed tasks exactly as specified (so the person knows precisely what results should come out at what times) and to avoid getting into bad programming habits.

Assignment features

he

  • Defines a class 'Adventurer' (Worth 2.0 GPA)
 
  •  Defines two private attributes: 'health' (type int) and 'name' (type String) (Worth 0.4 GPA)
 
  • Methods:
     
  • A no argument constructor that sets the name and health attributes to the following starting values (e.g., "nameless" for the name and -1 for the health (Worth 0.4 GPA)
  • A 'gainLevel()' method that displays a message onscreen ("Congratulations!") and increases health by 5. (Worth 0.4 GPA)
  • An accessor ('get)' method called 'getHealth()' method that returns the value of the health attribute. (Worth 0.2 GPA)
  • An accessor ('get)' method called 'getName()' method that returns the value of the name attribute. (Worth 0.2 GPA)
  • A mutator ('set)' method called 'setHealth()' method that sets the value of the health attribute to the parameter passed into it. (Worth 0.2 GPA)
  • A mutator ('set)' method called 'setName()' method that sets the value of the name attribute to the parameter passed into it. (Worth 0.2 GPA)
     
  • Defines class 'Driver'. The 'main()' method will contain the following instructions (Worth 2.0 GPA )
 
  • Declares a reference to an 'Adventurer'. (Worth 0.3 GPA)
  • Creates/instantiates an  Adventurer object by calling the default constructor. (Worth 0.3 GPA)
  • Displays the health and name of the adventurer using the two 'get' methods, the default values should appear. (Worth 0.4 GPA)
  • Uses the mutator methods to set the name to 'Balin' and health to 10. (Worth 0.4 GPA)
  • Calls the 'gainLevel()' method of the adventurer. (Worth 0.2 GPA)
  • Displays the health and name of the adventurer again via the get methods, the new values should appear 'Balin' and 15 (Worth 0.4 GPA)

Marking:

Important 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. Alternate submission mechanisms (non exhaustive list of examples: email, uploads to cloud-based systems such as Google drive, time-stamps, TA memories) cannot be used as alternatives if you have forgotten to submit work or otherwise have not properly submitted into D2L. Only files submitted into D2L by the due date is what will be marked, everything else will be awarded no credit.
  2. Late submissions will not be accepted for mini-assignments. Make sure you give yourself enough time to complete the submission process so you don't get cut off by D2L's deadline (when you get a zero).
  3. Extensions may be granted for reasonable cases by the course instructor with the receipt of the appropriate documentation (e.g., a sworn declaration with a commissioner of oaths). Typical examples of reasonable cases for an extension include: illness or a death in the family. Example cases where extensions will not be granted include situations that are typical of student life: having multiple due dates, work commitments etc. You should mitigate the occurrence of technical problems by submitting your work early and often and early in D2L as well as performing regular backups. Do not expect to get an extension if something like this has occurred.
  4. 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 you submit your assignment with enough time before it comes due for you to do a check).
  5. Identifying information: All assignments should include contact information (full name, student ID number and tutorial section) at the very top of your program in the class where the 'main()' method resides (starting execution point). (Note other documentation is also required for most of the full assignments).
  6. 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].
  7. Execution: programs must run on the computer science network (if applicable during that particular semester) running the latest version of Java (this is what applies for the distance learning version of the course). If there libraries or classes external to what's included in Java then you must include clear and complete instructions for your marker as to exactly what needs to be done to compile and run your submission otherwise you may be awarded no credit. Also you should be wary of using external libraries rather than writing the code yourself because you may not be awarded credit for particular features if you didn't write the code yourself. If you write you code in the lab and work remotely using a remote login program such as Putty or SSH then you should be okay (assuming you don't login to a non-Linux computer). 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 up to you if you wish use the graphical program builder to write/run your programs but if you do you submit your program in the form of text ".java" file or files.
  8. Use of pre-created  libraries: unless otherwise told you are to write the code yourself and not use any pre-created classes. For this assignment the usual acceptable functions include code in the Scanner class and methods for displaying output such as: printf()print()println().

Submitting your work: