问题描述
我有一个叫做 House
的类.此类的实例是 house
.
I have a class called House
. The instance of this class is house
.
class House:
def __init__(self, height, length):
self.height = height
self.length = length
def housePlan():
houseHeight = self.height
houseEdgeLength = self.length
house = House(height,length)
我还有一个叫做 Person
的课程.此类获得一些输入,包括 House
的实例.
I have another class called Person
. This class gets several inputs including an instance of House
.
class Person:
def __init__(self,name, house):
self.name = name
self.house = house
问题我想向观众展示我的程序,我如何将这些关系与图表展示出来?
Question I would like to present my program to an audiance, how I can present these relationships with diagrams?
推荐答案
House 的实例不仅在 Person 的构造函数的参数中给出,而且是类的属性( self.house = house
),因此:
the instance of House is not only given in argument of the constructor of Person but it is a property of the class (self.house = house
), so :
我说过 name 是很有可能的 String .
所有属性/属性/操作都是公开的,以遵守Python规则.
All attributes / property / operations are public to respect Python rules.
在类图的级别上,无法看到操作的参数来自何处,因为您可以使用交互(例如,在您下一个问题中的序列图,我也将一个 answer )或一项活动
At the level of a class diagram it is not possible to see from where the arguments of the operation come from, for that you can use an interaction (e.g. a sequence diagram like in your next question where I also put an answer) or an activity
(奇怪的是,您的房子只有长度但没有宽度,因此必须是正方形)
(Out of that it is strange your house has a length but not a width, so it is mandatory a square)
这篇关于如何表示一个类的实例与将该类作为输入的类之间的关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!