Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
-1 S CIENTIFIC P ROGRAMMING 23 Checkpoint 6 Aim of Checkpoint This checkpoint will provides a simple introduction to the object-oriented programming technique. You will create an object that represents a circle, add instance methods for accessing the properties of the circle, and add class methods for general use with circle objects. This checkpoint is worth 20% of the course mark. Submission Dates Final submission date for this checkpoint is: 5.00 pm, Thursday 31 October The Circle Object A circle can be completely defined, in two-dimensional Cartesian space, by its radius and the coordinates of its centre. These properties provide the basis for defining an object that represents a circle and directly correspond to the class variables in a Java class. A circle also has other well defined properties that we could imagine that it would be useful to include in a circle object. These include, amongst others, the circumference and area of the circle and correspond to instance methods in a Java class. That is, the values are associated with a particular circle object rather than circle objects in general. We can also imagine a number of useful operations that we would like to perform on mutliple circle objects. For example, it is often useful to know if two cricles overlap. This type of operation best corresponds to a class method in a Java class. Checkpoint Task You should write a class that represents a circle object and includes the following: 1. Private class variables that store the radius and centre coordinates of the object. 2. Constructors to create circle objects with nothing supplied, with just a radius value supplied and with a radius and centre coordinates supplied. 3. Public instance methods that allow the radius and centre coordinates to be set and retrieved (often known as set/get methods). 4. Public instance methods that return the circumference and area of the circle. 5. A public class method that tests if two circle objects overlap or not. Once you have written your class you should write a program that proves that the object and all of the the methods function as expected. (Note: Although the class itself is realtively straightforward you will produce more code than you might expect and this will be the largest Java program you have written so far.) S ESSION 2012/2013 V ERSION 6.0, 27 S EPTEMBER 2011 S CIENTIFIC P ROGRAMMING -2 End of Checkpoint When you have completed both your programs call a demonstrator and show them the code, compile it and demonstrate the working program. This is the end of checkpoint 6. Ensure that the demonstrator checks off your name. Material Needed In addtion to the material for Checkpoint 5 you will need material from the following sections: 1. Introduction to Methods. 2. Introduction to Objects, What Next? If you started at Checkpoint 1 then congratulations you have completed the course. If you started at Checkpoint 4 then you should go on and attempt Checkpoint 7. S ESSION 2012/2013 V ERSION 6.0, 27 S EPTEMBER 2011