File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Hash Table, Hash Map, Linked List of objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hash Table, Hash Map, Linked List of objects" Watch "Hash Table, Hash Map, Linked List of objects" New topic
Author

Hash Table, Hash Map, Linked List of objects

amofa baffoe
Greenhorn

Joined: Mar 31, 2006
Posts: 6
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.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
amofa baffoe
Greenhorn

Joined: Mar 31, 2006
Posts: 6
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
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19073
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
amofa baffoe
Greenhorn

Joined: Mar 31, 2006
Posts: 6
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?
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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?


There is no emoticon for what I am feeling!
amofa baffoe
Greenhorn

Joined: Mar 31, 2006
Posts: 6
yes
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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

Joined: Mar 31, 2006
Posts: 6
don't worry, there are a lot of forums out there
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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


Nicer too.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hash Table, Hash Map, Linked List of objects