LAB #4: CLASSES


1. Task: Create a Point class. The class should contain 2 fields (integers called x and y, for the x and y coordinates, positive values) and the following methods:


2. Task: Create a client for the Point class. Be very thorough with your testing (including invalid input) and have output similar to the sample output below:

 

---After declaration, constructors invoked--- Using toString():

First point is (0, 0)

Second point is (7, 13)

Third point is (7, 15)

Second point (7, 13) lines up vertically with third point (7, 15)

Second point (7, 13) doesn't line up horizontally with third point (7, 15)

Enter the x-coordinate for first point: retgre

Not an integer! Try again! Enter the x-coordinate for first point: 89.67

Not an integer! Try again! Enter the x-coordinate for first point: -13

ERROR! Should be positive. Enter the x-coordinate for first point: 15

Enter the y-coordinate for first point: fwgfe

Not an integer! Try again! Enter the y-coordinate for first point: 90.6

Not an integer! Try again! Enter the y-coordinate for first point: -32

ERROR! Should be positive. Enter the y-coordinate for first point: b

Not an integer! Try again! Enter the y-coordinate for first point: 23

First point (after call to set) is (15, 23)

Distance from origin for first point =  27.46

Distance from origin for second point =  14.76

Distance between first point and second point =  12.81

First point (after call to translate (5, 10)) is (20, 33)

Second point (after call to translate (15, 5)) is (22, 18)

---Call to equals: The 2 points are NOT equal.

---Calls to copy and print--- 

First point (after call to copy) is (20, 33)

Second point (after call to copy) is (20, 33)

---Call to equals after call to copy: The 2 points are equal.


Notes:
A. The lab will NOT be graded, do NOT hand anything in to the instructor.
B. The lab should be completed by the start of the next scheduled lab class. Save the .java files on your disk and e-mail them (attachments) to Vishal Patel at vpatel12@students.towson.edu
Very important: Make sure that you have COSC 237.section, your name, and Lab#4 in the Subject box of your e-mail.
C. In case you have any problems, contact the instructor or the TA for assistance.