This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: ASSIGNMENT 4 Records and Objects COMP-202B, Winter 2010, All Sections Due: Wednesday, March 31, 2010 (23:55) You MUST do this assignment individually and, unless otherwise specified, you MUST follow all the general instructions and regulations for assignments. Graders have the discretion to deduct up to 10% of the value of this assignment for deviations from the general instructions and regulations. Part 1, Question 1: 0 points Part 1, Question 2: 0 points Part 2, Question 1: 65 points Part 2, Question 2: 35 points 100 points total Part 1 (0 points): Warm-up Do NOT submit this part, as it will not be graded. However, doing these exercises might help you to do the second part of the assignment, which will be graded. If you have difficulties with the questions of Part 1, then we suggest that you consult the TAs during their office hours; they can help you and work with you through the warm-up questions. Warm-up Question 1 (0 points) Create a file called MyPoint.java which contains a class called MyPoint . This class should define two attributes of type double called x and y . Inside this class, declare a public and static method called main() ; this method should create create an instance of class MyPoint whose address in memory is stored in variable p . Assign values to the x and y fields of the object whose address is stored in reference variable p , then display the values of these fields using System.out.println() . Warm-up Question 2 (0 points) Create a file called MyTest.java which contains a class called MyTest . Inside this class, declare a public and static method called main() ; this method should create an instance of class String whose address in memory is stored in variable s . This instance of class String should represent the character String "COMP 202" . Call the contains() method multiple times, using the reference variable s as a target, but passing a different actual parameter value ( "OMP" , "C" , "T" , "20" , and so on) each time; observe the values returned by the calls to the contains() method by displaying them using System.out.println() . Part 2 (65 + 35 = 100 points) The questions in this part of the assignment will be graded. Question 1: Garage Car Management Application (65 points) In this question, you will be creating a small garage management application. This application will be 1 create and maintain an array of Car records; the concept underlying this application is similar to that of a database system, but with far fewer details. Each Car record will have six fields. The first five fields represent a car’s make (of type String ), its model (of type String ), its year (of type int ), its serialNumber (of type long ), and the number of repairs made on the car ( numberRepairs , of type int ) that the system has tracked. The last field, named repairs , is an array of Repair objects which will keep track of the last ten Repair s performed on the Car ....
View Full Document
This note was uploaded on 10/16/2010 for the course COMP 202 taught by Professor Verbrugge during the Winter '07 term at McGill.
- Winter '07