I've coded the beginning menu which is fine. The next part I was going to code was the main booking option. The way our teacher has set out this model code is that we're suppose to pass attributes down from route > day > pod and the route itself is passed to the customer and it's flight. We were told to create all the possible flight routes in constructor of the Day class (Why, this I don't really understand).
The current part I'm stuck on is implementing the choice "b" to book. Example IO given to us is along the lines of:
While getting the S.o.p is simple, I'm unsure of how I'm suppose to be passing these attributes down as the switch code for booking is:
I don't really understanding why the base code we were given to work off of passes routes down as the variable when we want to begin booking.
Kevin Thien wrote:I don't really understanding why the base code we were given to work off of passes routes down as the variable when we want to begin booking.
I have to admit, I share your confusion slightly; but your teacher may be making a distinction between the booking process and an actual ticket.
Sometimes it's worth turning OFF your computer and stepping back from the business of coding to analyse the components you're dealing with. And make your notes (or diagrams) in English.
If I see it right, you might end up with definitions like this:
1. Route - A point-to-point transfer operated by an Airline.
2. Airline - A carrier company that operates Flights that cover designated Routes.
3. Flight - A scheduled transfer over a Route in one direction, operated by a specific Airline.
4. Trip - An itinerary of Flights required to complete a journey.
Hopefully you get the idea. Going through that sort of process may help you to follow what's being asked of you - and maybe ask questions about the rest. Unless your teacher is a complete duffus, there's absolutely nothing wrong with questioning a design.
Personally, I don't like the idea of a Route containing a book() method either. I'd have put it in the Flight class and had it return a Ticket. But there may well be a need for a generalized search of a Route when you're trying to book, for Flights that go on a particular day for example; and maybe that's what the method is intended to do (if so, I think I'd have called it flights() though).
Sounds like a good exercise though, because now you're starting to get a feel for what programming is really about.
Airline has Routes and Customers. Routes have route. Route has Days. Days have Pods. Customers have Customer. Customer has Trip. Trip has routes and a Flight. Flight has a route.
What I don't really get is why it's passing down route as a variable. I can code the S.o.p and corresponding variable input, S.o.p("Destination"); destination = In.nextLine(); as well as the validity checks.
Kevin Thien wrote:Route has Days. Days have Pods...Trip has routes and a Flight.
I have to admit that these 3 are a bit odd.
First: What is a Day? If it's a "calendar day" or a "day of the week" then it's likely to be affected by timezone (and BTW, most airlines work in Zulu time (GMT) - at least the one I worked for did). If it's simply a 24-hour period starting from some arbitrary point, that seems a lot more reasonable; but then the key doesn't make much sense.
Second: What is a Pod? Is it some acronym like 'Point of Departure'?
Third: I can see why a Trip might equate to a set of Routes, but then why only a single Flight?
Seems to me like you need to get the specifics of this stuff sorted out in your own mind; and I suspect the only thing that will help you with that is a Vulcan mind-meld with your teacher.
Winston Gutkowski wrote:Third: I can see why a Trip might equate to a set of Routes, but then why only a single Flight?
The Trip is not a collection of Routes, it is a collection of Flights. The Routes object is passed in to Trip for a purpose, but you will notice there is no place to store it, and you will notice it is passed in again in the only other method in Trip, so the intent is not to store Routes in Trip.
Routes consists of a list of Route objects. It has methods to look up a route based on source and destination, but also note there is no method used to add a Route to the collection. I think this is enough to deduce what Routes is intended to be (and from that why you need it when trying to book a flight).
Steve Luke wrote:The Trip is not a collection of Routes, it is a collection of Flights. The Routes object is passed in to Trip for a purpose, but you will notice there is no place to store it, and you will notice it is passed in again in the only other method in Trip, so the intent is not to store Routes in Trip.
Quite right. I was going by OP's description instead of looking at the classes. I still reckon this Day and Pod business is rather confusing though, but maybe they're explained better in the requirements doc.
I also question the logic of having a Trip made up of Flights, because that suggests to me that it's the result of a booking process. If I walk into a Travel agent, I will presumably already have a Trip planned; what I won't have is any knowledge about Routes or Flights or Pods.
To me, the result of a booking process is a Ticket (or Tickets) ... and, no doubt, a Payment.
The source and destination are definitely being picked up cause I can see them in my S.o.P debug, but they won't initialise my times array properly. I'm racking my brain on this right now and I can't figure it out.
*EDIT I'm an idiot with strings. Fixed it with a stupid way.
Now my issue is with
How do I make it not print "Not available" for each instance of the array it checks?