Question: Problem Definitions Implementation of Design Options: This problem is adapted from Section 2 . 9 of our required text ( starting on page 5 7

Problem Definitions
Implementation of Design Options: This problem is adapted from Section 2.9 of our required
text (starting on page 57). Assuming you are a software analyst on a project that requires ex-
tensive (in millions) rotation of points and computation of the distance between any
two points and performance is key to the success of the project. However, to realize this, you are
allowed to store a point either in its Polar or Cartesian coordinates formats. For example, you may
choose to store a point in its Polar form but provide interfaces to convert or store it in its Cartesian
form and vice-versa. In its Cartesian state, you will be storing the 'x' and 'y' coordinates of the
point while you will be storing its distance from a reference point (r) and theta - an angle from
the reference direction () in its Polar state.
r=x2+y22,
=tan-1(yx),
x=r*cos,
y=r*sinEquations (1)-(4) show expressions for converting between attributes of Polar (i.e.,'r' and '') and its counterpart - Cartesian (i.e.,'x' and ?'y') coordinates. In the figure below, we provide class designs of PointCP and PointCPTest whose implementations can be downloaded from: PointCP - PointCP.java and PointCPTest - PointCPTest.java.
\table[[PointCP],[getX()],[getY()],[getTheta()],[getRho()],[getDistance(Object point)],[rotatePoint(double rotation)]]
\table[[PointCPTest],[main()]]
Table 1: Alternative designs for PointCP class
\table[[Design,\table[[How Cartesian coor-],[dinates are computed]],\table[[How Polar coordi-],[nates are computed]]],[\table[[Design 2(D2) : Store polar coor-],[dinates only (i.e., create proper-],[ties for polar coordinates)]],\table[[Computed on demand,],[but not stored (with cor-],[responding methods).]],\table[[Simply returned (with],[corresponding methods).]]],[\table[[Design 3(D3) : Store Cartesian],[coordinates only]],\table[[Simply returned (with],[corresponding methods).]],\table[[Computed on demand,],[but not stored (with cor-],[responding methods).]]],[\table[[Design 5(D5) : Abstract super-],[class with designs 2 and 3 as sub-],[classes.]],\table[[Depends on the concrete],[class used.]],\table[[Depends on the concrete],[class used.]]]]
You are required to do the following:
Modify the original implementation of PointCP.java to reflect Design 5 in Table 1. In particular, you will end up with implementations of (D5,D52,D53). You are allowed to modify implementations of methods: getDistance(...) and rotatePoint(...) as you deem fit to ensure consistency with other implementations. You are to hand-in a working code for each of the implementations that you have written.
 Problem Definitions Implementation of Design Options: This problem is adapted from

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!