Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Java language. Please follow the instructions bellow: Point Class The contents of the file should include: o Triangle modified appropriately o Point modified appropriately

Using Java language. Please follow the instructions bellow: image text in transcribed
image text in transcribed
Point Class
image text in transcribed
The contents of the file should include: o Triangle modified appropriately o Point modified appropriately o Scalable interface o Your test class including: Main method that calls the other methods . Your sorting method . Your method for creating the random array Your method for enlarging/shrinking objects - Your file should be able to be compiled using the command: javac Ashley S.java and ran using java Ashleys,where Ashley is replaced by your own name. This is to be completed individually. Any and all collaboration is strictly prohibited and will result in a zero for the assignment. All questions regarding details of the assignment specifications should asked to me only. You will use the create Triangle class and use Point from lab 4 for this assignment. Part A. Write out the Triangle class from: Triangle - + sidel: double side2: double side3: double Triangle() Triangle (s: double) Triangle (si: double, s2: double, s3: double) setSides(si: double, s2: double, s3: double) getSides(): double toString(): String areal): double equals(t : Triangle): boolean + Make Triangle implement the comparable interface. These objects should be ordered based on area. Write a sorting method for an array of these objects. (Use selection or insertion sort only). Part B. Make an interface that is called Scalable. It should have two functions: the ability to enlarge or shrink an object. Make Triangle Scalable Using Point class from lab 4, make Points Scalable as well. (You may ignore the z values if you want) For both classes, provide an explanation for your enlarge and shrink methods implementation. Part C. Create an array of random Triangles and Points. (There should be a random mixture of all the objects) o Random points should be generated using random integers values from the interval [-50,50] for both x and y values. (You may just keep z values as default o values.) o Random Triangles should be created by generating two random integers in the interval [1,100], say x and y. From these values for the sides are computed as: . x2 - y2 - 2xy . x2 + y2 Write a method to go through the array and : enlarge a Point if it's within distance of 20 from the origin, otherwise shrink the Point. enlarge a Triangle if its area is less than the average area of all the Triangles in the array and shrink it otherwise. Point - - - x: int y: int z: int + Point ( //should create the origin (0,0) + Point (x: int, y:int) //should create (x,y,0) + Point (x: int, y:int, z: int) //should create (x,y,z) + distance (Point p): double // should return the distance between the 2 points + distanceFromOrigin (): double //should return the distance from (0,0) + toString(): String //should return the point in the form "(x,y,z)" + equals (Point p): boolean 1/2 points are equal if x,y,z values are all equal + translate (x: int, y:int): Point + translate (x: int, y:int, z: int) : Point (Hint: remember to add the get and set methods) Distance between two points is: (x1 - x2)2 + (y1 - y2)2 + (x - 2)2 Translating a point is: creating a new point where the x value is the x of the original point plus the parameter, similarly for y and z. Ex. P =(3, -6) and we want to use translate (1, 2) then we should get P2 =(4,-4)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

How autonomous should the target be left after the merger deal?

Answered: 1 week ago