0% found this document useful (0 votes)
3 views46 pages

Adavanced project report 1

Adavanced project report 1 documentation for the project

Uploaded by

tarek hadef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views46 pages

Adavanced project report 1

Adavanced project report 1 documentation for the project

Uploaded by

tarek hadef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

CSE 231 : Advanced Programing

Project report

Group members :
• Abdelrahman Khaled alkawwa ( 21p0285)

• Aley Amin Shakr (21p0150)

• Seif Eldin Samir (2101524)


Project description :
The travel management system enables employees in any travel agency to
manage trips and tours which are organized by the company.
- There are different categories of trips, like: Safari holidays, Adventure tour,
Culture trip, Religious tour.

- Each Tour trip consists of:


o Trip date.
o Trip category.
o Trip name.
o Tour guide.
o Number of tourists who can join this tour.
o Total number of tourists who joined this trip and their personal information.
o The details of the sites that the tourists will visit.
o Price of the trip
o The total profit which came out of this trip.

- Each tour guide has:


ID, name, age, salary, and information about the trips to which he is assigned to
before.

Each client has his personal information plus information about trips he has.
- Client’s trips can be divided into previous trips, current trip (if he is in a trip now),
and coming trips (trips that doesn’t start yet).
-
This application should enable the employee to:
▪ Add, edit, or cancel any tours or trips organized by the company.
▪ Add, edit, delete, and view tour guide information.
▪ Assign each tour guide to specified tour based on his availability.
▪ Add, edit, delete, and view personal details of clients.
▪ Cancel client’s coming trip if the client wants that.
▪ Postpone a client’s trip if there is another trip to the same site that will take
place soon.
▪ Calculate the total profit for each category of trips separately.
▪ Finally, he can get the total profit of all trip categories.
UML diagram :
Our classes :
1. Client
2. Tour
3. Tourguide
4. Travelagency (abstract)
5. Date
6. Project

Here the Travelagency class serves as the parent class to Client


class , Tourguide class ,and Tour class.

Project class contains our main method .


• Travelagency (abstract class):

1) Attributes :

2) Methods
• Setters/getters : used to access private elements
• Abstract methods : used to act as a blueprint to all child
classes that extend this class

• Constructor : used to initialize values


• Find ---- byID: this method is used to take an index
(interger) as a parameter then transverse through the
array list till the element with the provided index is found
which is done using a for-loop
• Clients class :

1) Attributes :

2) Methods used :

• Constructors : used to initialize the values


• Setters/getters : used to access private elements
• toString method: is an in built method that returns the
value given to it in string format

• add --- method : in built method that is used to add


elements to an arraylist
• edit ---- method : used to replace an element from arraylist
by firstly creating a new object to store in the object we
want to replace (which we got with the help of findclientid
method) then we check whether our object equals ‘null’ if
not we use corresponding (setter) to reset the element as
we want
• deleteClient method : used to delete a client object from
arraylist using getClients (getter) to access private
members followed by remove built-in method

• cancelClientTour : is a method that takes in 2 parameters


which are both integers (clientID) and (tourID) we first
create 2 objects of types Client and Tour so that we store
in them the returned objects from the findClientbyID and
findTourbyID methods then we check if either of them
equals ‘null’ if not we set the tour to null and remove the
client
• checkToPostpone:
a method that checks if a client's tour can be postponed. It first
finds the client by their ID, then creates a new Date object. If
the client is found, the function iterates through all of their
tours. For each tour, it checks if the tour date is upcoming (using
the CheckIfUpcomingDate() method). If the tour date is
upcoming and the tour sites are the same as the client's current
tour, then the function calls the postponeClientTour() method
to postpone the tour.
• postponeClientTour:
is a method that postpones a client's tour. It takes the client ID,
the ID of the current tour, and the ID of the new tour as input
(all integers ) . the method first finds the client, the current tour,
and the new tour by their IDs. If all three are found, the method
then sets the client's current tour to null, removes the client
from the current tour's list of clients, adds the client to the new
tour's list of clients, and then sets the client's current tour to
the new tour
• viewClientInformation:
is a method that prints the information of all clients in a
list. It takes a list of clients as input and iterates through
the list, printing the information of each client to the
console.
• Tourguide class

1)Attributes

Methods used :
• Constructors : used to initialize the values
• Setters/getters : used to access private elements
Edit --- method:

methods to used edit the information of a tour guide.

The methods are:


1 editId(): This method edits the ID of the tour guide.
2 edit(): This method edits the age of the tour guide.
3 editSalary(): This method edits the salary of the tour
guide.
4 editAssignedTours(): This method edits the list of tours
assigned to the tour guide.

The editId(), edit(), and editSalary() methods first navigate the


tour guide by their ID. If the tour guide is found, then the
corresponding information is updated.

The editAssignedTours() method first finds the tours with the


specified IDs. If the tours are found, then the tour guide is
removed from the first tour and added to the second tour.
addTourGuide : in built method that is used to add elements to
an arraylist
• deleteTourGuide:
method to delete a tour guide. The method takes the ID of
the tour guide as input and removes the tour guide from
the list of tour guides.

• viewTourGuideInformation: will print the information of


all tour guides in a list
• assignTourGuideToTour:
this method first finds the tour guide and the tour by their
IDs. If the tour guide and the tour are found, then the tour
guide is added to the list of tours assigned to the tour
guide and the tour is set to the tour guide.
• Tour class:

Attributes :
Methods:

• Constructors : used to initialize the values


Setters/getters : used to access private elements
• add --- method : in built method that is used to add
elements to an arraylist
• Edit---: methods first find the tour by its ID. If the tour is
found, then the corresponding information is updated.

• editName(): This method edits the name of the tour.

• editId(): This method edits the ID of the tour.

• edit(): This method edits the maximum number of clients


for the tour.

• editDate(): This method edits the date of the tour.

• editCategory() method first finds the tour by its ID. If the


tour is found, then the category of the tour is updated.

• editTourGuide() method first finds the tour guide and the


tour by their IDs. If the tour guide and the tour are found,
then the tour guide of the tour is updated.

• The editSites() method first finds the tour by its ID. If the
tour is found, then the sites of the tour are updated.

• The editPrice() method first finds the tour by its ID. If the
tour is found, then the price of the tour is updated.

• The editProfit() method first finds the tour by its ID. If the
tour is found, then the profit of the tour is updated.
Canceltour: This method first finds the tour by its ID. If the tour
is found, then the tour is removed from the list of tours.

calculateCategoryProfit : this method first iterates through the


list of tours. For each tour, it checks if the tour's category is
equal to the specified category. If it is, then the profit of the
tour is added to the category profit.
calculateTotalProfit: this method first iterates through the list of
tours. For each tour, it adds the profit of the tour to the total
profit.The method then returns the total profi

addClients: the method first finds the client and the tour by
their IDs. If the client and the tour are found, then the client is
added to the list of clients for the tour and the tour is added to
the list of upcoming tours for the client.
• Date class

Methods :
Constructor :

Getters:
CheckIfUpcomingDate:
This method first compares the year, month, and day of the current date
and the specified date.
If the year of the specified date is less than the year of the current date,
then the specified date is not upcoming.
If the years are equal, then the method compares the months of the two
dates.
If the month of the specified date is less than the month of the current
date, then the specified date is not upcoming.
If the months are equal, then the method compares the days of the two
dates.
If the day of the specified date is less than the day of the current date, then
the specified date is not upcoming. Otherwise, the specified date is
upcoming .The method returns 0 if the specified date is upcoming and -1 if
the specified date is not upcoming.
Our main method :

public class Project {

public static void main(String[] args) {


Scanner input = new Scanner(System.in);
Tour tour = new Tour();
TourGuide tourguide = new TourGuide();
Client client = new Client();
int countMain = 0;
System.out.println("Can you please enter your name");
String name = input.next();
System.out.printf("Hi %s what would you like to do today.
%n",name);

while (countMain == 0){


System.out.println("What would do you like to manage:");
System.out.println("Press 1 for Tours \nPress 2 for Tour
Guides \nPress 3 for Clients\n");
int firstChoice;
firstChoice = input.nextInt();
while (firstChoice > 3 || firstChoice < 1){
System.out.println("Please enter a number from what's
mentioned above");
firstChoice = input.nextInt();
}
switch(firstChoice){
case 1 -> {
int countTour = 0;
while (countTour == 0){
System.out.println("What do you want to do with
Tours:");
System.out.println("Press 1 to add Tour \nPress 2 to
edit Tour \nPress 3 delete Tour \n");
int secondChoice = input.nextInt();
while (secondChoice > 3 || secondChoice < 1){
System.out.println("Please enter a number from
what's mentioned above");
secondChoice = input.nextInt();
}
switch(secondChoice){
case 1 -> {
int countAddTour = 0;
while (countAddTour == 0){

tour.addTour(tour);
System.out.println("Please enter the tour's
information");
System.out.println("Id");
tour.setT_Id(input.nextInt());
System.out.println("Date in this format
DDMMYYY only numbers!!");
tour.setT_Date(input.nextInt());
System.out.println("Category");
System.out.println("Press 1 for Safari holidays
\nPress 2 for Adventure tour \nPress 3 for Culture trip \nPress 4
for Religious tour \n");
int thirdChoice = input.nextInt();
while (thirdChoice > 4 || thirdChoice < 1){
System.out.println("Please enter a number
from what's mentioned above");
thirdChoice = input.nextInt();
}
switch(thirdChoice){
case 1 -> tour.setT_Category("Safari
holidays");
case 2 -> tour.setT_Category("Adventure
tour");
case 3 -> tour.setT_Category("Culture trip");
case 4 -> tour.setT_Category("Religious
tour");
}
System.out.println("Name");
tour.setT_Name(input.next());
System.out.println("Max number of clients");
tour.setT_maxClients(input.nextInt());
System.out.println("Sites");
tour.setT_sites(input.next());
System.out.println("Price");
tour.setT_price(input.nextInt());
System.out.println("If you want to add
another thing press 0 if not press 1");
countAddTour = input.nextInt();
}
}
case 2 -> {
int countTourEdit = 0;
while(countTourEdit == 0){
System.out.println("Enter Tour Id");
int id = input.nextInt();
tour = tour.findTourById(id);
System.out.println("What do you want to edit
:");
System.out.println("Press 1 to edit name, Id
and Max Clients \nPress 2 to edit Date , Category and Tour Guide
\nPress 3 to edit Sites , Price and Profit\n");
int fourthChoice = input.nextInt();
while (fourthChoice > 3 || fourthChoice < 1){
System.out.println("Please enter a number
from what's mentioned above");
fourthChoice = input.nextInt();
}
switch(fourthChoice){
case 1 -> {
System.out.println("Enter the apropriate
replacements");
tour.editName(id, input.next());
tour.editId(id , input.nextInt());
tour.edit(id, input.nextInt());
}
case 2 -> {
System.out.println("Enter the apropriate
replacements Category from 1 to 4 respectively ");
tour.editDate(id, input.nextInt());
tour.editCategory(id , input.nextInt());

tour.editTourGuide(input.nextInt(),input.nextInt(),id);
}
case 3 -> {
tour.editSites(id, input.next());
tour.editPrice(id, input.nextInt());
tour.editProfit(id, input.nextInt());
}
}
System.out.println("If you want to edit
another thing press 0 if not press 1");
countTourEdit = input.nextInt();
}
}
case 3 -> {
int countTourDelete = 0;
while(countTourDelete == 0){
System.out.println("Enter Tour Id");
int id = input.nextInt();
tour = tour.findTourById(id);
tour.cancelTour(id);
System.out.println("If you want to delete
another thing press 0 if not press 1");
countTourDelete = input.nextInt();
}
}
}
System.out.println("If manage tours again press 0 if
not press 1");
countTour = input.nextInt();
}
}
case 2 -> {
int countTourGuide = 0;
while (countTourGuide == 0){
System.out.println("What do you want to do with
Tour Guides:");
System.out.println("Press 1 to add Tour Guide
\nPress 2 to edit Tour Guide \nPress 3 to delete Tour Guide
\nPress 4 to view Tour Guides \nPress 5 to Assign Tour Guide \n");
int fifthChoice = input.nextInt();
while (fifthChoice > 5 || fifthChoice < 1){
System.out.println("Please enter a number from
what's mentioned above");
fifthChoice = input.nextInt();
}
switch(fifthChoice){
case 1 -> {
int countAddTourGuide = 0;
while (countAddTourGuide == 0){
tourguide.addTourGuide(tourguide);
System.out.println("Please enter the Tour
Guide's information");
System.out.println("Id");
tourguide.setTg_Id(input.nextInt());
System.out.println("Name");
tourguide.setTg_Name(input.next());
System.out.println("Age");
tourguide.setTg_Age(input.nextInt());
System.out.println("Salary");
tourguide.setTg_Salary(input.nextInt());
System.out.println("If you want to add
another thing press 0 if not press 1");
countAddTourGuide = input.nextInt();
}
}
case 2 -> {
int countEditTourGuide = 0;
while (countEditTourGuide == 0){
System.out.println("Enter Tour Guide Id");
int id = input.nextInt();
tourguide = tourguide.findTourGuideById(id);
System.out.println("What do you want to edit
:");
System.out.println("Press 1 to edit name, Id ,
Age and Salary \nPress 2 to edit Assigned Tours\n");
int sixthChoice = input.nextInt();
while (sixthChoice > 2 || sixthChoice < 1){
System.out.println("Please enter a number
from what's mentioned above");
sixthChoice = input.nextInt();
}
switch(sixthChoice){
case 1 -> {
System.out.println("Enter the apropriate
replacements");
tourguide.editName(id, input.next());
tourguide.editId(id , input.nextInt());
tourguide.edit(id, input.nextInt());
tourguide.editSalary(id, input.nextInt());
}
case 2 -> {
System.out.println("Enter New Tour Id
and Old Tour Id respectively");
tourguide.editAssignedTours(input.nextInt(),input.nextInt(),id);
}
}
System.out.println("If you want to edit
another thing press 0 if not press 1");
countEditTourGuide = input.nextInt();
}
}
case 3 -> {
int countTourGuideDelete = 0;
while(countTourGuideDelete == 0){
System.out.println("Enter Tour Guide Id");
int id = input.nextInt();
tourguide = tourguide.findTourGuideById(id);
tourguide.deleteTourGuide(id);
System.out.println("If you want to delete
another thing press 0 if not press 1");
countTourGuideDelete = input.nextInt();
}
}
case 4 -> {

tourguide.viewTourGuideInformation(tourguide.getTourGuides());
}
case 5 -> {
int CountAssignTourGuide = 0;
while(CountAssignTourGuide == 0){
System.out.println("Enter Tour Guide Id");
int id = input.nextInt();
tourguide = tourguide.findTourGuideById(id);
System.out.println("Enter Tour Id");
int tourId = input.nextInt();
tourguide.assignTourGuideToTour(id, tourId);
System.out.println("If you want to assign tour
guide to tour again press 0 if not press 1");
CountAssignTourGuide = input.nextInt();
}
}

}
System.out.println("If you want to manage tour
guides again press 0 if not press 1");
countTourGuide = input.nextInt();
}
}
case 3 -> {
int countClient = 0;
while (countClient == 0){
System.out.println("What do you want to do with
Clients:");
System.out.println("Press 1 to add Client \nPress 2 to
edit Client \nPress 3 to delete Client \nPress 4 to view Clients
\nPress 5 to Cancel Client Tours \n");
int seventhChoice = input.nextInt();
while (seventhChoice > 6 || seventhChoice < 1){
System.out.println("Please enter a number from
what's mentioned above");
seventhChoice = input.nextInt();
}
switch(seventhChoice){
case 1 -> {
int countAddClient = 0;
while (countAddClient == 0){
client.addClient(client);
System.out.println("Please enter the Client's
information");
System.out.println("Id");
client.setC_Id(input.nextInt());
System.out.println("Name");
client.setC_Name(input.next());
System.out.println("Age");
client.setC_age(input.nextInt());
System.out.println("Current Tour Id");
int addCurrentTourId = input.nextInt();
tour = tour.findTourById(addCurrentTourId);
client.setC_currentTour(tour);
System.out.println("If you want to add
another thing press 0 if not press 1");
countAddClient = input.nextInt();

}
}
case 2 -> {
int countEditClient = 0;
while (countEditClient == 0){
System.out.println("Enter Client Id");
int id = input.nextInt();
client = client.findClientById(id);
System.out.println("What do you want to edit
:");
System.out.println("Press 1 to edit name and
Id\nPress 2 to edit Age\n");
int eigthChoice = input.nextInt();
while (eigthChoice > 2 || eigthChoice < 1){
System.out.println("Please enter a number
from what's mentioned above");
eigthChoice = input.nextInt();
}
switch(eigthChoice){
case 1 -> {
System.out.println("Enter Name then
Id");
client.editName(id, input.next());
client.editId(id , input.nextInt());

}
case 2 -> {
System.out.println("Enter Age");
client.edit(id, input.nextInt());
}
}
System.out.println("If you want to edit
another thing press 0 if not press 1");
countEditClient = input.nextInt();
}
}
case 3 -> {
int countClientDelete = 0;
while(countClientDelete == 0){
System.out.println("Enter Client Id");
int id = input.nextInt();
client = client.findClientById(id);
client.deleteClient(id);
System.out.println("If you want to delete
another thing press 0 if not press 1");
countClientDelete = input.nextInt();
}
}
case 4 -> {
client.viewClientInformation(client.getClients());
}
case 5 -> {
int countClientCancel = 0;
while(countClientCancel == 0){
System.out.println("Enter Client Id");
int id = input.nextInt();
System.out.println("Enter Tour Id");
int tourId = input.nextInt();
client.cancelClientTour(id, tourId);
System.out.println("If you want to cancel
another thing press 0 if not press 1");
countClientCancel = input.nextInt();
}
}
case 6 -> {
int countClientPostpone = 0;
while(countClientPostpone == 0){
System.out.println("Enter Client Id");
int id = input.nextInt();
client.checkToPostpone(id);
System.out.println("If you want to postpone
another clients tour press 0 if not press 1");
countClientPostpone = input.nextInt();
}
}
}
System.out.println("If manage clients again press 0 if
not press 1");
countClient = input.nextInt();
}
}
}
System.out.println("If you want to do another process press
0 if not press 1");
countMain = input.nextInt();
if (countMain == 1)
System.out.println("Thank you for using our app");
}
}

You might also like