• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Help with progressing in my Assignment

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not looking for direct answers, but rather help in getting onto the right direction in regards to what I'm doing. My assignment is a text-based airline booking ticket. I'll past all the code given and that I've coded so far and explain my thought processes. There's a few things I'm totally confused about right now and would LOVE some help in understanding what I should be doing next.











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.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Consider this: a customer gets to this screen and for the source types London and the destination types Cairo. Is this valid? How do you know? More importantly, how would the method know?
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

Winston
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Winston is correct, first you need to understand what the purpose is for each class or source file. Then connect them using flow chart finding the logic of the booking process. From there you will able to start coding.

Good luck
 
Kevin Thien
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We were actually given a design flow for his model solution which actually gave me the most confusion. The client chart flow was:

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.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first question to answer is: What does Routes do? It has 'Route' objects, but what is the purpose of Routes, what action does it do, or what data is it supposed to hold?

The next question is: Why does the customers.book() method need that/those actions or data.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

Winston
 
Kevin Thien
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Been a while since I've posted back but I've got most of my things to work. Currently I'm trying to get a check done for the time a user inputs and validating with my array of times. Currently I'm getting my array to be null and I can't figure out why.



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?
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic