英文:
UML class diagram Clarification I want to make sure if the rules needed are fulfilled
问题
以下是翻译好的部分:
我正在创建一个汽车租赁项目,在这个项目中,客户可以管理客户、汽车、停车、预订、合同、账单和处罚。这是我的UML类图:
我不确定是否满足以下规则:
一个客户可以租用一个或多个已经存在于停车场的汽车。
我不确定这是否应该是汽车和客户之间的简单关联,还是是否应该将停车场也添加进去,从而成为三个类之间的关联。
感谢您的提问!
英文:
I am creating a car rental project where a customer can manage clients, cars, parking, reservations, contracts, bills and sanctions. this my UML class diagram :
I am not sure if this rule is fulfilled :
A customer can rent one or more cars that already exist in the parking lot.
I am not sure if it will be a simple association between the car and the customer or should I add the parking also to make it an association between 3 classes.
Thanks,
答案1
得分: 0
使用当前的设计可能会变得复杂。如果您引入一个名为CarStock
的对象,其中包含所有Vehicle
及其当前状态,这将更容易实现。当前的设计要求Client
与所有Vehicle
建立关联以选择其中一个。请记住工作方式:您前往租车公司请求一种车型,然后获得一辆车。您不需要查看公司拥有的所有车辆列表(从而获知谁租了哪辆车)。此外,Reservation
和Vehicle
之间的关系需要是一对一的。
Client
与Bill
之间的关联是多余的,因为客户已经通过合同进行了身份确认。
英文:
With the current design that might turn out to be tricky. If you would introduce a CarStock
which holds all Vehicle
s and their current status, this would be much easier. The current design requires Client
to have associations to all Vehicle
s in order to pick a single one. Remember how things work: you go up the rental company and ask for a car type and you get one. You don't go through the list of all cars owned by the company (thereby having insight who rented which car). Furher the relation between Reservation
and Vehicle
needs to be a 1--1.
The assocation Client
-Bill
is superfluous since the customer is already identified via the contract.
专注分享java语言的经验与见解,让所有开发者获益!
评论