1 |
Practice Midterm Exam Handout for e01a |
CS56 M16 |
Name: | |
---|---|
(as it would appear on official course roster) | |
Umail address: | @umail.ucsb.edu |
e01a: Practice Midterm Exam Handout
ready? | date | points |
---|---|---|
true | Thu 07/07 09:30AM |
INSTRUCTIONS FOR QUESTION 1
Write the code for the IndexEntry
class, per the instructions below.
…
BoxLayout manager 411
brain barbell 33
break statement 105
BufferedReader 454
BufferedWriter 453
buffers 453
byte 51
bytecode 2
…
Books such as textbooks have an index in the back to help you find topics easily. Consider, for example, a fragment of the index of our CS56 textbook shown in the box at right. Each of these entries shows only one string (a topic) and then an integer which is the page on which that topic appears. For simplicity, assume for now that a topic appears on one and only one page (that is not true in practice, but for now, assume that it is.)
You will write a Java class to represent one entry in this index. For full credit, your class should have all of the following. Go over this as a "checklist" when you are finished to make sure you have everything needed.
Note that for this exam, you do NOT need to include Javadoc comments.
- (10 pts) Correct syntax and structure of a Java class.
- (8 pts) Private instance variables for the data members (attributes).
-
(8 pts) A two-argument constructor that takes arguments for the topic and the page number
Example invocation:IndexEntry ie = new IndexEntry("BoxLayout Manager",411);
-
(8 pts) getter methods called
getTopic
andgetPage
.
-
(8 pts) setter methods called
setTopic
andsetPage
.
-
(8 pts) a correct
toString()
method. The method should return the topic followed by the page number, separated by a single space.
NOTE: You do NOT need to implement an equals() method for this exam. We’ll cover that topic on midterm 2.
Total Points: Total points: ?