CPSC 233: Mini-Assignment 4
Due at 4 PM. For
assignment due dates see the main
grid on the course webpage.
New Concepts to be applied for the assignment
-
Working with Java Hierarchies:
interfaces, abstract classes, child classes
-
Overriding methods and calling
parent methods
-
Representing hierarchical
relationships and the protected level of access permission using UML class
diagrams
Description
To get credit for this assignment
you must use the starting interface and class definitions [Location
of starting code] because this
assignment will build on the code provided in those files. Unless explicitly
mentioned in the assignment you cannot modify the existing code in the interface
and these classes. You can (actually must) add new code specified to the classes
in order to get credit.
Class
Car:
- Implement the body of the
method start()
which sets the engineOn
attribute to true.
- Write the
header definition1 for the
abstract method travelOneUnit()
which takes no arguments and returns void.
Because the method is abstract it should not have curly braces to enclose a
body.
Class
Compact:
- Write the body for method travelOneUnit()
which is non-abstract in this class. The method will reduce the fuel of the
car by the amount specified by the named constant defined in this class
FUEL_CONSUMPTION.
Because the fuel
attribute is private to class Car,
the travelOneUnit()
method must make the change via the
consumeFuel() method of class
Car.
Class
SUV:
- Write the body for method travelOneUnit()
which is non-abstract in this class. The method will reduce the fuel of the
car by the amount specified by the value stored in the named constant
defined in this class, SUV,
FUEL_CONSUMPTION.
(Note: the value of the constant will be different value than the value
stored in class Compact!)
Again the consumeFuel()
method of class Car
must be used to change the value of the fuel attribute.
- Write the body the method
toggleAllWheelDrive()
which flips the state of the attribute
allWheelDriveEngaged.
Class
Driver (the previous features need to be
implemented first)
- In specified location in
main() before the second
set of output messages write the code to get the cars in each of the array
elements to travel 1 unit using the
travelOneUnit() method.
- In specified location in
main() before the third
set of output messages write the code to get the SUV to toggle the AWD
mechanism using the toggleAllWheelDrive()
method.
1 A
header definition includes: method name, return type and parameter information.
UML class diagram
Draw out a UML diagram for the
following classes: Car,
Compact,
SUV,
as well the Vehicle
interface.
Make sure you use the correct notation
for the attributes, methods, access permissions and relationships. Don't use the 'lollipop' notation
for the interface because you need to specify the method signatures.
Marking:
-
If you have questions about your marking then the
first person to talk to is your marker and that will be the person who
teaches the tutorial in which you are officially registered. [Tutorial
information] If you still have questions after this first step then feel
free to contact your course instructor, just let me know that you talked to
your TA first. Please do not come to the course instructor without taking
the time to consult your TA first.
-
TAs will download this sheet and each student will get
detailed feedback on this sheet (to be uploaded in the D2L Dropbox) about
how their grade point was derived: [Marking spreadsheet].
- Marking feedback. You will get a detailed marking
sheet for each assignment that contains your TA's feedback. This marking
sheet is uploaded in your D2L Dropbox. If you don't know how to access files
that have been uploaded into D2L then follow this link [viewing
uploaded files in the D2L Dropbox]
Important points to keep in mind:
- 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.
- 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.
- 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).
- What to submit: Java
programs should be submitted in the form of .java source
code. Do not submit .class files.
- 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).
- 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].
- 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.
- 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().
- 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).