In Lab 2, you will explore the concepts of class composition. What is a point? A...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In Lab 2, you will explore the concepts of class composition. What is a point? A point has two coordinates x and y. If we have two points, we can compute the distance between the two points. What is a line? A line has two points. If we have a line, we can get the length (distance) of that line. The following UML diagrams show the relationship of the two classes, and the main method: -intx -inty Point +Point() +Point(int x, int y) > +Point(Point p) +int getX() +int getY() +void set(int x, int y) -double distance(Point p) + double getDistance(Point p) 1..1 O+String toString( A 1..1 1..1 1..1 -p2- MainLab_2 -static Random rand -Point p1 -Point p2 + Line() + Line (Point p1, Point p2) +Line(Line aline) + double getDistance() +Point getP10) O+Point getP20 +void set(Point p1, Point p2) + String to String( -static int getInt() -static void getTwoPoints (Point p1, Point p2) + static void main(String] args) Implement the two classes based on the above UML diagrams. You can add in more methods but not remove any method from the UML. Line In the main method, you have to, randomly, generate a few Line objects and display the Line info. Some of the methods or info that I listed in the MainLab_2's UML, you need to implement and use them. For example, a method generates and returns a random integer; a method generates and returns the two random points. You can add in more methods Upon executing of your program, the following output will be displayed on the monitor screen: Set 1 Given Point (66, 36) Given Point (78, -83) Line (Point (66, 36), Point (78, -83), distance = 119.6035) Set 3 Given Point (52, 86) Given Point (70, 14) Line (Point (52, 86), Point (70, 14), distance = 74.2159) Set 2 Given Point (-13, 90) Given Point (39, 16) Line (Point (-13, 90), Point (39, 16), distance = 90.4434) Set 4 Given Point (89, 24) Given Point (23, -68) Line (Point (89, 24), Point (23, -68), distance = 113.2254) Set 5 Given Point (27, 84) Given Point (-27, -45) Line (Point (27, 84), Point (-27, -45), distance = 139.8463) In Lab 2, you will explore the concepts of class composition. What is a point? A point has two coordinates x and y. If we have two points, we can compute the distance between the two points. What is a line? A line has two points. If we have a line, we can get the length (distance) of that line. The following UML diagrams show the relationship of the two classes, and the main method: -intx -inty Point +Point() +Point(int x, int y) > +Point(Point p) +int getX() +int getY() +void set(int x, int y) -double distance(Point p) + double getDistance(Point p) 1..1 O+String toString( A 1..1 1..1 1..1 -p2- MainLab_2 -static Random rand -Point p1 -Point p2 + Line() + Line (Point p1, Point p2) +Line(Line aline) + double getDistance() +Point getP10) O+Point getP20 +void set(Point p1, Point p2) + String to String( -static int getInt() -static void getTwoPoints (Point p1, Point p2) + static void main(String] args) Implement the two classes based on the above UML diagrams. You can add in more methods but not remove any method from the UML. Line In the main method, you have to, randomly, generate a few Line objects and display the Line info. Some of the methods or info that I listed in the MainLab_2's UML, you need to implement and use them. For example, a method generates and returns a random integer; a method generates and returns the two random points. You can add in more methods Upon executing of your program, the following output will be displayed on the monitor screen: Set 1 Given Point (66, 36) Given Point (78, -83) Line (Point (66, 36), Point (78, -83), distance = 119.6035) Set 3 Given Point (52, 86) Given Point (70, 14) Line (Point (52, 86), Point (70, 14), distance = 74.2159) Set 2 Given Point (-13, 90) Given Point (39, 16) Line (Point (-13, 90), Point (39, 16), distance = 90.4434) Set 4 Given Point (89, 24) Given Point (23, -68) Line (Point (89, 24), Point (23, -68), distance = 113.2254) Set 5 Given Point (27, 84) Given Point (-27, -45) Line (Point (27, 84), Point (-27, -45), distance = 139.8463)
Expert Answer:
Related Book For
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba
Posted Date:
Students also viewed these programming questions
-
(a) Use the following text to derive distributions for rat and chased. Use a five-word window, including open- and closed- class words, ignore case, punctuation and sentence boundaries and weight...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
A six-lane freeway (three lanes in each direction) in a scenic area has a measured free-flow speed of 88.5 km/h. The peak-hour factor is 0.80, and there are 8% large trucks and buses and 6%...
-
Footnote 7 of Ann Taylor Stores Corp.'s financial statements for fiscal year 2014 contains the following information: 7. Commitments and Contingencies Operating Leases The Company occupies its retail...
-
What is the danger of continuing the splitting step portion of the classification tree algorithm too long?
-
What the requirements are for bringing a class action lawsuit?
-
The following data represent the responses to two questions asked in a survey of 40 college students majoring in business: What is your gender? (M = male; F = female) and What is your major? (A =...
-
Homework 11: Problem 11 (1 point) Consider the graph below. Find the equation for the line tangent to the graph at the point (9, 5). Write your answer in slope-intercept form. (y-1) = 4(x-5)
-
Determine the moments of inertia I x and I y of the area shown with respect to centroidal axes respectively parallel and perpendicular to side AB. 60 mm 320 mm 40 mm so mm 80 inm 330 mm 80 mm
-
Question 1 You advise your parents on investing in financial markets and do some preparation work. Your parents are interested in buying banking stocks and want to know more about the risk that a...
-
Discuss the significance of the modernist short story form in the works of authors like Katherine Mansfield or James Joyce. How do these writers experiment with narrative structure and perspective to...
-
Given that 42-2, 6xx + 1 dx = 42 - 2, what is 6uu + 1 du? Need Help? Read It
-
Analyze the conventions of the graphic novel medium as a form of literary expression. How do graphic novelists like Alan Moore or Art Spiegelman use visual storytelling techniques to convey complex...
-
For which types of applications were NoSQL systems developed? Which type of database does not use a rigid schema? Why
-
Given: F(s) s5+2s4+4s3+ s +3 3+s+3 s6+7s5+3s4+2s3+s+3 What is the syntax for Numerator and Denominator?
-
The following information was provided in the 2020 10-K of International Lodgings, Inc. Note 7: Property and Equipment ($ millions) 2020 2019 Property and equipment, gross $998 $1,067 Accumulated...
-
Before the 1973 oil embargo and subsequent increases in the price of crude oil, gasoline usage in the United States had grown at a seasonally adjusted rate of 0.57 percent per month, with a standard...
-
City Wage Taxes: In the U.S., very few cities tax income derived from wages while the national government imposes considerable taxes on wages (through both payroll and income taxes)and then passes...
-
Competitive Provision of Health Insurance: Consider the challenge of providing health insurance to a population with different probabilities of getting sick. A. Suppose that, as in our car insurance...
-
In the Hollywood movie A Beautiful Mind, Russel Crowe plays John Nash who developed the Nash Equilibrium concept in his PhD thesis at Princeton University. In one of the early scenes of the movie,...
-
Fill in the Blank. In a random process, the outcome of an experiment will be a function of some _________ such as time.
-
What is the covariance between two random variables \(X\) and \(Y\) ?
-
The joint density function of two random variables \(X\) and \(Y\) is given by \[p_{X, Y}(x, y)= \begin{cases}\frac{x y}{9}, & 0 \leq x \leq 2,0 \leq y \leq 3 \\ 0, & \text { elsewhere }\end{cases}\]...
Study smarter with the SolutionInn App