I want to do a simple program called "Ticketer", where you can:
- add new event with number of tickets available
- assign a ticket to customer.
I am not sure how to properly Design classes.
This is what I've got so far:
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
Can you please tell me in if that's a good approach and guide me, in general, step by step how to do this program ?
Thank You
cdomination
6031 gold badge7 silver badges25 bronze badges
-
1"Proper" is subjective and depends on your requirements. Your simple design might be fine for a simple demonstration, but you might find that it'll be hard to extend. That's the curse all designers live with.duffymo– duffymo2016年07月14日 18:57:07 +00:00Commented Jul 14, 2016 at 18:57
-
yes but is it doable ? i mean when i create Object Event can I automaticly create EventTicket objects for QuantityOfTickets times ?rafalbballer– rafalbballer2016年07月14日 19:16:18 +00:00Commented Jul 14, 2016 at 19:16
-
Anything can be done. Your requirements aren't clear. Personally I think this is a naive design, but I'm not going to write one for you. Try something, test it, learn from it, refactor to correct shortcomings. That's all anyone can do.duffymo– duffymo2016年07月14日 19:17:43 +00:00Commented Jul 14, 2016 at 19:17
1 Answer 1
I recomend another structure:
Class Event
Name
Date
QuantityOfTickets (can be removed and use instead of it length of array of tickets)
EventTicket tickets[QuantityOfTickets]
Class EventTicket
TicketNumber
(and if you will need additional fields (not from Event))
Class Customer
Id
FistName
LastName
EventTicket customerTickets[QuantityOfTicketsForThisCustomer]
any questions on it?
answered Jul 14, 2016 at 19:02
Roman Evseenko
1681 silver badge7 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
rafalbballer
does EventTicket needs customer field ? so i could check which tickets are not assigned to anyone ? also i have a question about customerTickets[QuantityOfTicketsForThisCustomer]-is it really needed ? I dont see where is relationship between ticket and customer assigned to ticket. Thank You .
Roman Evseenko
EventTicket (in my opinion) doesn't need customet field. To find tickets are not assigned to anyone you can check that this tickets are not in included into list of tickets for all customers, but at this case, possible will be better to has additional field at Event class "also i have a question about customerTickets[QuantityOfTicketsForThisCustomer]-is it really needed ? I dont see where is relationship between ticket and customer assigned to ticket." In fact customer is owner of ticket and ticket object shouldn't know anything about it, but customer should know.
lang-java