The class Triangle2D contains: Three points named p1, p2, and p3 of the type MyPoint (UML Class Diagram provided as reference) Mutators and accessor for all data members A no-arg constructor that creates a default triangle with the points (0, 0), (1, 1), and (2, 5). A constructor that creates a triangle with the specified points. A method getArea() that returns the area of the triangle. A method getPerimeter() that returns the perimeter of the triangle. A method contains(MyPoint p) that returns true if the specified point p is inside this triangle (see Figure a). A method contains(Triangle2D t) that returns true if the specified triangle is inside this triangle (see Figure b). A method overlaps(Triangle2D t) that returns true if the specified triangle overlaps with this triangle (see Figure c) (a) (b) (c) Question No. 1 (5 Points) Draw the UML diagram for the class Triangle2D. (NO PARTIAL CREDIT WILL BE GIVEN)
Added by Trevor S.
Close
Step 1
This means we need to have methods to set and get the points of the triangle. Show more…
Show all steps
Your feedback will help us improve your experience
Gokul R Nair and 50 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Question 3: Write the class definition for the UML below: MonthlyCarSales -saleMonth: String -saleValue: double +MonthlyCarSales() +MonthlyCarSales(mth: String, val: double) +setSaleMonth(nm: String): void +setSaleValue(val: double): void +getSaleMonth(): String +getSaleValue(): double +toString(): String 3.1 In another class with a main method, write Java statements to generate random sales values for 12 MonthlyCarSales objects using the Random class. The sales values must be in the range of 2 to 500. Assign the objects to an array. 3.2 Write Java statements to determine and display the highest sales value and the month in which it occurred. Use the JOptionPane class to display the output. Do the same for the lowest sales value.
Akash M.
Q-1- Write a program to create a class named Shape. In this class, we have three subclasses: Circle, Triangle, and Square. Each class has two member functions named draw() and erase(). Create these using polymorphism concepts. Q-2- Write a program to give an example of multiple inheritance in Java. Q-3- Write a program to give a simple example for an abstract class.
Madhur L.
Write the class definition for an Employee using the following UML: Employee -empName: String -empSurname: String -empNumber: String -empSalary: double +Employee() +Employee(n: String, sn: String, num: String) +setEmpName (nm: String): void +setEmpSurname (snm: String): void +setEmpNumber (num: String): void +setEmpSalary (sal: double): void +getEmpName(): String +getEmpSurname(): String +getEmpNumber(): String +getEmpSalary(): double +increaseSalary(amt: double): void +toString(): String The argument of the increaseSalary() method is a value representing the percentage increase required. Now write another class that contains a main method in which you use both constructors to construct 2 Employee objects. Use the Scanner class to enter values for all the instance variables. Now call the appropriate method/s to display the property values for each object. Increase the salary of each object by 10% and 15% respectively (use the Scanner class for input). Now display the property values for each object again.
Willis J.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD