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

CPSC 233: Mini-Assignment 3

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

You are to write part of a computer simulation. 'Entities' inhabit a 'World'. You are given the code for the 'Entity' class definition which can be found [here]. Use this code when you implement class 'World' and the 'Driver' class. The latter will be starting execution point of the program containing the main method. You will receive credit for implementing the following capabilities in the World class. Although you aren't awarded direct credit for writing a proper Driver class it's obviously needed to run your program (but the Driver should be short - my solution was only two lines long).

 Features of class World

  • Declares a 2D 5x5 "array of Entities". Each element refers to an Entity object. (Worth 0.1 GPA)
  • Defines a constructor which initializes each array element to 'null'. The element at [1][1] will refer to an Entity object (the starting location of the one entity in the simulation). (Worth 0.3 GPA, 0.2 initializing the entire array, 0.1 for specifying the correct starting location of the Entity)
  • Using nested loops the simulated world will be displayed. The appearance of an array element depends upon whether it is empty (space character) or the one element that refers to an Entity object (an X appears in the starting code for program but if the appearance is changed to another character (e.g. E then your program should display an 'E' and no an 'X' ). That is, the display of the Entity is based on the current value of the appearance attribute. (Worth 0.4 GPA, 0.2 GPA for each case)
  • Each element is bound above, below, left and right by a line (see Figure 1).  (Worth 1.2 GPA if every element bounded in the 4 directions).

    Cases where every cell is bounded except for the following:

    • Misses one of the following: top row, bottom row, left row, right row. (Worth 1.0 GPA)
    • Misses two of the following: top row, bottom row, left row, right row. (Worth 0.8 GPA)
    • Misses three of the following: top row, bottom row, left row, right row. (Worth 0.6 GPA)
    • Misses all of the following: top row, bottom row, left row, right row. (Worth 0.4 GPA)

    Cases where only the outer boundary is bounded:

    • Only the very top AND the bottom is bounded: Worth 0.2 GPA)
    • Only the very top OR the bottom is bounded: Worth 0.1 GPA)
 
Figure 1: The display of array elements bounded in the four directions (starting location of object at [1][1])
  • Loop the display of the world until the user enters a negative location for the row or column (next feature). (Worth 0.1 GPA)
  • (1) Prompts the user for the destination (row/column) to move the entity. (2) A negative value for either coordinate will end the program (regardless of what value was entered for the other coordinate e.g., (-1/-1), (-1,0), (20,-22) will all end the program). (3) A value outside the bounds of the array will result in an appropriate error message, non-negative out-of-bound values will still allow the program to prompt again as long as the other coordinate is not negative. (Worth 0.6 GPA, 0.2 GPA for each feature)
 
Figure 2: Any out-of-bound destinations will result in an error message. Any negative coordinates will end the simulation program.
  • (The previous feature must be implemented first). Assuming that no out-of-bound coordinates have been entered, the program "moves" the entity to the specified destination. The previous cell will appear 'empty' (space) whereas the destination will take on the appearance of the entity ('X' in the starting code). Movement must work for multiple turns in order to get credit (and not just 'apparently' work for one turn and thereafter producing an incorrect result). (Worth 1.3 GPA, 0.7 GPA for properly setting the destination cell, 0.6 GPA for properly setting the source cell)

To help you see the operation of the various features there is a sample output file in the assignment directory: [output.txt]

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. 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. If you request an extension from me let me know the name of your tutorial instructor and the tutorial number because the markers won't accept late submissions without directly getting an email from me.
  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 you submit your assignment with enough time before it comes due for you to do a check).
  4. What to submitJava programs should be submitted in the form of .java source code. Do not submit .class files.
  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. Students should not see each other's graded programs (don't post it, don't email it out, don't show it in a screen share). 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().
  9. 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).

Submitting your work:

  • What to submit.
  • The document must be electronically submitted using D2L.
  • It's recommended that you submit your work early and often to avoid problems such as forgetting the due date or problems with your computer (hardware failures, malicious programs etc.). Reminder: you will not be granted special considerations such as extensions in these cases!
  • D2L configuration for this course
    • Multiple submissions are allowed for this assignment (all versions are kept in D2L): You can (and really should) submit work as many times as you wish before the due date. Due dates are strict, only what is in D2L by the deadline is what will be marked. Other methods of verifying that your work was completed on time (e.g. checking timestamps, emailed files etc.) will NOT be accepted. However only the latest version of all the files is what will be marked, everything else will be ignored (because it is not fair to your marker to sort through multiple versions of your files).
  • Do not use compression utilities (such as zip) or archiving utilities (such as tar) otherwise your submission may not be marked. The space savings in D2L is not worth the extra time required by the marker to process each submission.
  • 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).