gpt4 book ai didi

Java类设计

转载 作者:行者123 更新时间:2023-12-01 09:42:00 25 4
gpt4 key购买 nike

我想做一个名为“Ticketer”的简单程序,您可以:

  • 添加新 Activity 以及可用门票数量
  • 向客户分配票证。

我不知道如何正确设计类。

这是我到目前为止所得到的:

Class Event
----
Name
Date
QuantityOfTickets-which is how many tickets that event have


Class EventTicket extends Event
-----------
ticket[QuantityOfTickets]-after creatting any Event class create an array of tickets for
as many as we set up in Event class.

TicketNumber
Object Customer
+3 fields from Event (Event.Name,Event.Date and Event.QuantityOfTickets)


Class Customer
-------------
Id
FistName
LastName

您能否告诉我这是否是一个好方法,并指导我一般情况下如何逐步执行此程序?

谢谢

最佳答案

我推荐另一种结构:

类(class) Activity

Name
Date
QuantityOfTickets (can be removed and use instead of it length of array of tickets)
EventTicket tickets[QuantityOfTickets]

类EventTicket

TicketNumber
(and if you will need additional fields (not from Event))

类客户

Id
FistName
LastName
EventTicket customerTickets[QuantityOfTicketsForThisCustomer]

对此有任何疑问吗?

关于Java类设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38382120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com