Jawapan Latihan Amali 2 (Design UML) 1. Class Name: Rectangle Role: To store length and width and calculate area and perimeter Attributes length: A variable to store the length of the rectangle width: A variable to store the width of the rectangle Behaviors Rectangle(l,w): A method that creates a Rectange by setting it’s length and width calculateArea(): A method to calculate the area of the rectangle using the formula: area = length x width calculatePerimeter(): A method to calculate the perimeter of the rectangle using the formula: perimeter = 2 x length + 2 x width A UML diagram for a Rectangle class is shown in Figure 1.1 below: 2. A UML diagram for a Temperature class is shown in Figure 13.4. /* File: Temperature.java * Description: This class stores the current temperature. * It contains access methods to set and get the temperature.*/ 3. A UML diagram for a TaxWhiz class is shown in Figure 1.4. 4.
© Copyright 2025 Paperzz