Question
python How do to create UML diagram for rectangle using the below format In UML class diagrams, data field are denoted as: dataFieldName: dataFieldType Constructors
python
How do to create UML diagram for rectangle using the below format
In UML class diagrams, data field are denoted as:
dataFieldName: dataFieldType
Constructors are shown as:
ClassName(parameterName: parameterType)
Methods are represented as:
MethodName(parameterName: parameterType): returnType
UMl circle example
Circle--------class name
Radius: float-----data field
Circle(radius=1: float)----constuctor
setArea(): float----methods
getPerimeter(): float----methods
setRadius(radius: float): None---methods
here are my code for the triangle class:
class Rectangle: """ Rectangle class """ def __init__(self, width=1, height=2): """ Constructor """ # Initializing private variables self.__width = width; self.__height = height; def getWidth(self): """ Function that returns width of a rectangle """ return self.__width; def getHeight(self): """ Function that returns height of a rectangle """ return self.__height; def getArea(self): """ Function that returns area of a rectangle """ return self.__width * self.__height; def getPerimeter(self): """ Function that returns perimeter of a rectangle """ return 2 * (self.__width + self.__height);
def main(): """ Main function """ # Creating object rect = Rectangle(4, 40); # Printing data print(" A " + str(rect.getWidth()) + " x " + str(rect.getHeight()) + " rectangle has an area of " + str(rect.getArea()) + " and a perimeter of " + str(rect.getPerimeter()) + ". "); # Creating object rect1 = Rectangle(3.5, 35.7); # Printing data print(" A " + str(rect1.getWidth()) + " x " + str(rect1.getHeight()) + " rectangle has an area of " + str(rect1.getArea()) + " and a perimeter of " + str(rect1.getPerimeter()) + ". ");
# Calling main function main();
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started