0

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

3
  • 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. Commented 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 ? Commented 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. Commented Jul 14, 2016 at 19:17

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

2 Comments

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 .
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.