Question: Exercise 1: Write a Point class that has xpos and ypos as its fields, get and set methods, and a toString method. It must be

 Exercise 1: Write a Point class that has xpos and ypos

Exercise 1: Write a Point class that has xpos and ypos as its fields, get and set methods, and a toString method. It must be written as a generic class, which means that it should work for any type of object, that is, the xpos and ypos could be either Integer objects, or Double objects, or String objects. A sample test program is given below. Modify the test program to accept input data from the user and try it for different input values. public class PointTester public static void main (String[ args) Point point! new Point(10, 20) ; PointDouble> point2 = new PointDouble> (14.5, 15.6); PointString> point3 = new Point("topleftx", "toplefty") System.out.println (pointl); System.out.println (point2); System.out.println (point3) The output is XPOS: 10 YPOS: 20 XPOS: 14.5 YPOS: 15.6 XPOS: topleftx YPOS: toplefty The following exercises (2 to 5) llustrate the concept of building data structures in "layers". You will design a Generic Stack and Generic Queue data structure using an ArrayList. Although an ArrayList itself is a generic data structure, the idea behind layering is that the arraylist can be changed to another data structure such as a linked list and the applications running the queue will not notice the difference

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!