Announcement

Collapse
No announcement yet.

Who knows Java

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Who knows Java

    Hi

    I need to design a Java program which records and displays the timetable of trains between station 'A' and station 'B'. The program should allow the user to:

    1. Add details of a new Train to the timetable.
    2. Delete a Train from the timetable by given the departure time from 'A' and the arrival time at 'B'.
    3. Find the fastest Train from 'A' to 'B'.
    4. Display the train timetable with the departure and arrival times and in departure time order.

    At the moment I've got very little idea how to go about this, or the best way to approach it. Any help would be greatl appreciated.

    Thanks

    G

    #2
    This is the completely wrong site for this kind of info mate.
    I'd try a site where more people have keen interest in programming.

    Comment


      #3
      I kinda thought that, but had hopes that there might be some Java genius out there somewhere.

      Thanks anyway Yashiro.

      Comment


        #4
        There probably are some Java bods on here to be honest. The percenatge will be low given this a forum for console games though. Plus they may come here to escape programming boredom.

        Best of luck with it mate.

        Comment


          #5
          Well, first off you'd need some kind of data storage for trains travelling between stations A and B...

          I'd go with something like their direction and their velocity in a simple little class and their arrival/departure state and times.

          You'd then need some kind of dynamic data storage for the timetable. The java.util package has a pile of storage classes like vectors, linked lists and hastables...

          Most of the rest is simply a matter of displaying data and whatnot.

          Unless you have a design you can't really start coding it anyways.

          Comment


            #6
            Yup - you need to think about the design first.

            A classic 3-tier system would lend itself to this.

            Your GUI for displaying the information on screen (the presentation layer)
            The logic for working out the calculations (the logic layer)
            And the access to your storage of the information (the data layer).

            The data layer will depend on whether you have to store these in anything other than memory, you could use a file or JDBC to access a simple database, you could probably get away with a single table, assuming that A and B are the only stations. Becomes a little more complex if A and B can be anything.

            TrainID
            Departure Time
            Arrival Time

            If it's more than just the two station, you'll need a station look up

            Train Table
            =======
            (Key) TrainID
            (Key) StationID
            ArrivalTime
            DepartTime

            Station Table
            =========
            (Key) StationID
            Description

            You could store this information in a text file too and just read it in to your timetable objects. You'll need to think about what methods and properties you'll need in your classes.

            Your program would need to look for all trains that go from A to B, and work out the time dif from the Arrival - Depart times. So in your logic layer you'd have a method that would do that.

            I assume you're being taught java atm, so you should be okay syntax wise, if you're not it's a tough assignment

            Hope that gives you some direction to head in.

            Regards
            Marty

            Comment

            Working...
            X