• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hash Table, Hash Map, Linked List of objects

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hash Table, Hash Map, Linked List of objects
Please, I need some help with the following project. Deadline is only next week friday 28th:

You are required to implement a flight reservation system. Firstly, create a class which will hold the details of a flight. This should include a flight number, departure and arrival cities and the date of departure. You should use all techniques of Object Oriented Design (such as encapsulation) with which you are familiar. Next, create a class which holds the passenger information. This should contain the name, e-mail address, and flight number for the passenger.

Now create a main application. You should create a three-cell hash table, where each cell is the head of a linked list. Add 5 flight objects to this table; the key being the flight number. Note that the flight number should consist of two letters followed by a three digit number. You may either ask the user to input the 5 flights, or read them in from a file; both are equally difficult. You should check to ensure that the flight number conforms to this standard. Your main application should create a tree (you may use the attached code). Allow the user to do the following:

1.Add a passenger to a given flight. This should cause the passenger to be inserted into the correct location in the tree. You may determine the correct location in the tree based on passenger name.
2.remove a passenger from a given flight. This should cause the correct rearrangement of the tree.
3.print out the passengers in alphabetical order. You might consider using a toString() method as part of the passenger class.

When taking in the passenger details, you should perform some checking.
1.A passenger may not be added to a flight that does not already exist.
2.a maximum of 5 passengers may be booked onto each flight
3.be creative and check other things as well.

In the project be sure to use the precepts of Object-oriented design. It is not enough to get the program working. Marks will be deducted for badly presented code or bad design. Note that the passenger and flight details are totally separate. The hash-table of flights is used to store flights and to look them up (thereby verifying the flight exists). The tree of passengers is used to store passengers only.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, well, what do you have so far? Tell us, and we will offer further suggestions. But we're not about to do your homework for you!

The first thing you'd want to do, most likely, is think about the various classes you'll need.
 
amofa baffoe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, the following is what I have. I am just confused with Has tables, linked list and the stuff, and hence this assignment:

package com.devx.travelagent.domain;

import java.util.Date;

public class Flight
{
private int flightNumber;
private String departure;
private Date departureTime;
private String destination;
private Date arrivalTime;

public Flight()
{

}

public Flight(int flightNumber, String departure, Date departureTime, String destination,
Date arrivalTime)
{
this.flightNumber = flightNumber;
this.departure = departure;
this.departureTime = departureTime;
this.destination = destination;
this.arrivalTime = arrivalTime;

}

public long getFlightNumber()
{
return flightNumber;
}

public String getDeparture()
{
return departure;
}


public Date getDepartureTime()
{
return departureTime;
}


public String getDestination()
{
return destination;
}


public Date getArrivalTime()
{
return arrivalTime;
}


public void setFlightNumber(long number)
{
this.flightNumber = flightNumber;
}


public void setDeparture(String departure)
{
this.departure = departure;
}


public void setDepartureTime(Date departure1Time)
{
this.departureTime = departure1Time;
}


public void setDestination(String destination)
{
this.destination = destination;
}


public void setArrivalTime(Date arrivalTime)
{
this.arrivalTime = arrivalTime;
}

}



class PassengerInfo //
{

// program to ** fill in as required ****
private String passengerName;
private String emailAdd;
private String flightNo;



public PassengerInfo()
{
passengerName = " ";
emailAdd = " ";
flightNo = " ";
}

public String getName()
{
return passengerName;
}


public String getAdd()
{
return emailAdd;
}

public String getNum()
{
return flightNo;
}

public void setName(String name)
{
passengerName = name;
}

public void setAdd(String add)
{
emailAdd = add;
}

public void setNum(String num)
{
flightNo = num;
}

}// end class
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am just confused with Has tables, linked list and the stuff, and hence this assignment:



Well, I am assuming that you were just taught Hash Tables and Linked Lists, and now have an assignment that you are suppose to use it on. However, instead of using the assignment as a "trial by fire", I think it would be better to address your confusion about Hashtables and Linked Lists, before doing the assignment.

So... what specifically are you confused about? Is it a particular issue with using the Hashtable and LinkedList classes? Using them in a particular way? Or are you confused at the concept level? etc.

Henry
 
amofa baffoe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Henry,

I don't think your response is in anyway helpful. I just need someone who really understand the assignment, help me do it and I will be able to understand from the done assignment. Can you actually help me in that way?
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by amofa baffoe:
I just need someone who really understand the assignment, help me do it and I will be able to understand from the done assignment.



So the best way to help you is to do the assignment for you, so that you can try to understand the "done" assignment?
 
amofa baffoe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by amofa baffoe:
yes


(sigh)

At the risk of feeding a troll, that's not the way JavaRanch works. It's up to you to put in the initial effort. The classes you posted were just examples of simple beans, with getters and setters -- there was no sign of hashing or hash tables or maps. If you are completely lost, this isn't the way to proceed. You need to start by studying. Have you read a tutorial : http://java.sun.com/docs/books/tutorial/collections/index.html, and have you tried to ask your instructor questions?
[ April 21, 2006: Message edited by: Jeff Albertson ]
 
amofa baffoe
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
don't worry, there are a lot of forums out there
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by amofa baffoe:
don't worry, there are a lot of forums out there



Let me suggest The Java Forums at Sun. They're smarter than us and should be able to code up your assignment in no time.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeff Albertson:
They're smarter than us and should be able to code up your assignment in no time.



Nicer too.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic