Been studying Java for a few weeks now and I still can't get to thinking like a programmer. I need to create an application where the user chooses between a daily unlimited rides ticket and a daily single rides ticket. Based on a user’s selection he/she is further given the choice of the various sub-categories within the chosen category. The user then enters the ticket quantities for the chosen sub-category. This process of choosing between the two main categories of unlimited and single rides tickets, and entering the number of tickets for the chosen sub-category needs to continue till the user elects to exit the program. For each iteration, a sub-total of the amount payable is displayed. Once the user exits the program, the user should be displayed with the total amount payable for all the tickets.
I'm thinking I may need to create a method that computes the price of the specific ticket purchased, but how do I give the user the option to continue or exit the program whilst showing the subtotal all the time. Also, what would be the best way to deal with the tickets and prices of each ticket? I was hoping there is a way to associate the price with ticket in a variable or something. And lastly, can someone give me an idea on how to apply the discounts for bulk purchases? I apologise in advance if I am asking a lot, you do not have to give me code, just point me in the right direction. Thanks
A good way to begin object oriented design is to look for nouns and verbs in your requirements. Nouns tend to be implemented as classes (e.g. Ticket). Verbs tend to be methods (e.g. calculatePrice()).
Look for is-a relationships which are often a hint towards inheritance (your case may not have this situation). Look for has-a relationships which would be aggregation (i.e. member variables or "fields").