Professional Documents
Culture Documents
Assignment 1
CE-206 Advanced Object Oriented Programming
i.e
a) Add the following methods in the above class
public void movePoint(int x, int y); // resetting x,y values w r t current values
public void changePoint(int x, int y);// resetting x,y values
public booleanequals(MyPoint p);
b) Add two constructors – one taking an x and y as parameters, the other setting the values
to 0.
c) Add a method that calculates and returns a MyPoint object that is exactly half-way
between the two points, i.e.,
MyPoint p1 = new MyPoint(0, 0);
MyPoint p2 = new MyPoint(4, 4);
MyPoint p3 = p1.findMidpoint(p2);
Advanced Object Oriented Programming Assignment # 1
Question # 2 :
a) Using MyPoint class. create a class that can
store circles, where each circle has an origin and a
radius.
b) Write methods to calculate the circumference
and area of a circle.
c) Write a method to determine whether two circles
intersect and a method to determine if two circles are
identical.
Question # 3:
The Polar Coordinate System is a two-dimensional coordinate system in which each
point on a plane is determined by a distance from a fixed point and an angle from a
fixed direction.
a) Design a class, PolarPointthat stores a fixed origin Point (that is shared by
all instances of the PolarPointclass and is initialed using Point origin
= new Point(0,0);) and a distance and angle from the reference point.
You can assume that the angle is always relative to an infinite line extending to
the right of the point (see diagram).
b) Converting between polar and cartesian coordinate systems can be done using
the sine and cosine operations.
x = r cos !+ xorigin
y = r sin !+ yorigin
c) Write a method that returns a Point in the cartesian coordinate system. You
may find the Math.cos(double a) and Math.sin(double a) methodsuseful.
I. Cartesian coordinates can be converted back to polar coordinates using
II. Write a function that calculates the shortest straight-line distance between two
PolarPoint objects (Hint: This may be easier using the cartesian coordinate
system).
Question #5:WAP that create a class for representing a complex variable consisting the
following information
1. Two instance hidden variable real and imaginary.
2. Two constructor’s i.e 1 default and other 2 augmented constructor.
3. Two get methods for accessing the values of instance variable.
4. Add methods that returns (object) the addition of two complex object.
5. Add methods that returns (object) the subtraction of two complex object.
6. Add methods that returns (object) the multiply of two complex object.