M/F 2:30-3:20 |
CS 1130: Transition to OO Programming Spring 2016 |
|||||||||||||||||||||||||||||||||||||||||
Main
About: Overview Announcements Staff Consultants Calendar Materials: Texts DrJava Terminology Lectures: In-Class Web-Based VideoNote Assessment: Grading Assignments Labs Resources: CMS Piazza (link) Piazza (about) Java API Style Guide Academic Integrity |
Monitoring RhinosDue to CMS by Friday, February 6th. The rhinoceros population is endangered, having declined 90 percent since 1970, with only five species remaining the world today. The white and black rhinos are the only species left in Africa. Much of the threat to the rhinoceros comes from poachers, who kill them for their horns. Recently, Kenya (with less than 500 rhinos left!) relocated 33 rhinos to Meru National Park, where they hope to protect them from poachers. When an animal population is small or endangerd, the animals are typically monitored in order to track the population. Sometimes these animals are captured and tagged. Some tags emit a signal, so that one can track the animal. Even in populated places, animals are tagged. Her in Ithaca, there are deer with tags on their ears wandering in the fields. If you keep your eyes peeled, it will not take long for you to see one.
Your task in this assignment is to develop a Java class Table of Contents
Before You Get StartedRead CarefullyIn order to give you as much guidance as possible, these instructions are fairly long. Your chances of completing the assignment quickly be increased by reading carefully and following all instructions. Many requests for resubmission are caused not by issues with programming but simply by not following instructions. We have tried to lay out the instructions in sections to make it clear as possible. You should pay particular attention to the section on Iterative Development, as it contains important instructions for the remaining sections, and we will not repeat these instructions for each section. Grading Policy (Revise-and-Resubmit Cycle)To ensure that everyone masters this assignment, we will use an iterative feedback process. If one of the objectives below is not properly met, we will give you feedback and expect you to revise and resubmit. This process will continue until you are done. This process should be finished by 18th of February; once you finish you will receive a perfect score of 10. In our experience, almost everyone is able to achieve a perfect score within two submissions. In grading your code, we will focus on the following issues:
Formatting is graded according to the course style guidelines, available on the course web page. Until we have decided that you have mastered (e.g. 100/100) the assignment, your "grade" on CMS will be the number of revisions so far. This allows us to we can keep track of your progress. Do not be alarmed if you see a "1" for the assignment at first! The assignment will be considered completed when it passes all three steps outlined above. Collaboration PolicyYou may do this assignment with one other person. If you are going to work together, then form your group on CMS as soon as possible. This must be completed before you submit the assignment. Both people must do something to form the group. The first person proposes, and then the other accepts. If you do this assignment with another person, you must work together. It is against the rules for one person to do some programming on this assignment without the other person sitting nearby and helping. Take turns "driving"; alternate using the keyboard and mouse. With the exception of your CMS-registered partner, you may not look at anyone else's code or show your code to anyone else, in any form what-so-ever. Assignment ScopeEverything that you need to complete this assignment should have been covered by Lecture 4 in class, or the first module in the web lectures. While you may have been exposed to them before you may not use if-statements anywhere in this assignment, as they are not necessary. Submissions containing if-statements will be returned for you to revise. Getting HelpIf you do not know where to start, if you do not understand testing, or if you are completely lost, please see someone immediately. This can be the course instructor, a TA, or a consultant. Do not wait until the last minute. A little in-person help can do wonders. See the staff page for more information. Working with DrJavaTo do this assignment, DrJava must be set up properly. If you have not already done this, follow the DrJava instructions to set it up on your computer. Next, you should adjust your DrJava preferences to make programming a littler easier. Open up the Preferences window, found in the Edit Menu. First, change the indent level; choose "Miscellaneous" in the Preferences window and change the entry "Indent Level" to 4. In addition, you should choose "Display Options" and check the box "Show All Line Numbers". Once you do that, you will find that you can properly format the code in your entire file simply by hitting the tab key once; DrJava will format everything automatically. Given the size of these tabs, however, you may find yourself with long lines that require you to scroll to the right to read them. We do not want to have to scroll to the right, so you should break up long lines (including both code and comments) into two or more smaller lines. Finally, you will want to create a folder on your hard drive that is dedicated to this assignment and this assignment only. Every time that you work on a new assignment, we want you to make a new folder, as otherwise it is easy to mix up your assignments. Initial Draft of Rhino
The first thing to get start is to create a skeleton class definition for class
First, you should add a file comment, which includes your name and the date on which you
completed the assignment. This should be a single-line comment (e.g. using the
Next you should add a JavaDoc class comment. A JavaDoc comment is a multi-line comment in-between
Instances of this class are monitoring data for a single rhino. Save this file into the new directory and compile it. You will want to compile often as you proceed. In general it is a good idea to compile every time you complete an objective. Class FieldsThe next thing to do when making a class is to create the fields. All of these fields should be private and properly commented. We have more instructions on commenting below. The fields for this class are as follows:
Class InvariantEvery field declaration should be accompanied by a comment. This comment should describe what the field means, the constraints on the field, and the legal values for the field. This type of comment is called an \emph{invariant}. The collection of invariants for all fields is called the class invariant For example, for the month-of-birth field, state in a comment that the field contains the month of birth and that it must be in the range 1..12. Here is an example of a declaration with a suitable comment:
Note the we do not JavaDoc style comments for fields in this class.
Do not include things like "(an int)" in a comment for a field. We only included that above so that you know what type the field should be. It is not needed in the comment because the type is obvious from the declaration. Iterative Development
You are not quite done yet with Skeleton of RhinoTester
Iterative development hinges on proper JUnit testing.
Create a new JUnit class in DrJava and call this class Instructions for the Remainder of the Assignment
The rest of the assignment is broken into five parts (listed Part A, B, C, D, and E). In each
part, you will work on a group of methods in
Remember: To run a JUnit test, have the class you are testing -- Writing Method SpecificationsThe descriptions that we provide in each part below represent the level of completeness and precision we are looking for in your Javadoc comments. In fact, it is best to copy and paste these descriptions to create the first draft of your Javadoc comments. If you do not cut and paste, please adhere to the conventions we use, such as using the prefixes "Constructor: ...", for constructors and "Yields: ..." for functions. You should also use double-quotes to enclose an English boolean assertion. Using a consistent set of good conventions in this class will help us all.
In our specifications, there are no references to specific field names, since the user may not
know what the fields are, or even if there are fields. The fields are private. Remember the class
JFrame: you know what methods it has, but not what fields, and the method specifications do not
mention fields. In the same way, a user of your class Part A: Constructor and GettersThe names of your methods must match those listed below exactly, including capitalization. The number of parameters and their order must also match: any mismatch will cause our testing programs to fail, meaning that you will have to resubmit. Parameter names will not be tested; you can change the parameter names if you want. ConstructorFor this part, you will write a single constructor. It will have the following form:
The specification for this method is as follows:
Your constructor should initialize all of the fields in the profile object to satisfy the specification above. You should \textbf{not write code that checks whether preconditions hold}. It is the responsibility of the caller to ensure that the precondition is met. This means, for example, that you should not worry about (or write code that checks for) a name that is null. GettersIn addition to the constructor, you should write several getter methods. The complete list of methods to write for this part is as follows:
Testing
Once you have created the constructor and getters, it is time to create your JUnit test. Your
first test will be in the procedure
There are eight fields, so you should be able to do this with eight Part B: Setters
Three of the fields in
Again, you should not write code to check whether the preconditions holds. For example,
Hint: The methods Testing
You will test these setter methods in the test procedure
As we said, the methods Part C: Another ConstructorYour next goal in this assignment to write a second constructor for the class. This constructor is a thorough constructor that initializes all of the fields, and not just a select few. It will have the following form:
The specification for this constructor is as follows:
Testing
The next round of testing should occur in the test procedure As before, you do not need to check that the preconditions are satisfied. That is the responsibility of the person using this class, not the person writing it. Part D:
|
Method | Description (JavaDoc Specification) |
---|---|
isOlder(Rhino p) |
Yields: "p is not null and this Rhino is older than p ".
|
isOlder(Rhino p, Rhino q) |
Yields: "p and q are not null and p is older than q".Make this function static and write it using the previous isOlder(Rhino) as a helper method.
|
When you are done with the last part of this assigment, you should test it in the test procedure
partE
. When you test the comparison methods, you should test them on a diverse and
representative set of inputs. In other words, think of all the different ways that the comparison
can be false, and all of the different ways in which it can be true; you should have at least one
test for each case.
Once you have everything working you should go back and make sure that your program is properly formatted so that we can easily read it. In particular, you should check that the following are all true:
The last step requires some additional explanation.
Recall that JavaDoc is how we create the web pages that you see in the Java API. In this class, we use it mainly to check that you have filled in all of your specifications correctly. Click the Javadoc button in DrJava and examine the output. You should see your method and class specifications.
Read through them from the perspective of someone who has not read your code, and fix them if necessary so that they are appropriate to that perspective. You must be able to understand everything there is to know about writing a call on each method from the specification that you see (e.g. without knowing anything about the private fields). Thus, the fields should not be mentioned.
Once you have done this, add a comment at the very top of your code saying that you checked the Javadoc output and it was OK. We will hold you to this, and if the JavaDoc is not okay, the assignment will be sent back for revision.
Upload files Rhino.java
and RhinoTester.java
on the CMS by
the due date: Friday, February 6th at 11:59PM. Do not submit any files with the
extension/suffix .java~ (with the tilde) or .class. It will help to set the preferences in your
operating system so that extensions always appear.
Check the CMS daily until you get feedback from a grader. Make sure your CMS notifications for CS 1130 are set so that you are sent an email when one of your grades is changed.
Within 24 hours, you should do the four Rs: Read the feedback, Revise your program accordingly, Resubmit, and Request a Regrade using the CMS. If you do not request a regrade, we have no simple way of knowing that you have resubmitted. The whole process should be finished within one week.