Sie sind auf Seite 1von 32

SYW

Name:
Chong Qian Chen (TP023441)
Ng Yung Hyun (TP019683)
Lim Pay Mun (TP019800)

Module:
Fundamental SoItware Development
(CT010-3-1-FSD)

Intake:
UC1F1007TC

Assignment Title:
Group Assignment

Lecturer:
Mr Yong Ket Wei

Due Date:
26rd November 2010



SYW


Table of Contents

No. Description No. of Pages
1 Cover Page 1
2 Table oI Contents 2
3 Introduction 3
4 Acknowledgement 4
5 Workload Matrix 5
6 Design oI the program
O Screen Print
O Flowcharts

6 11
12 14
7 Source code oI the program in Java 15 26
8 Sample outputs with explanation 27 28
9 Assumptions 29
10 Future Enhancement 30
11 Conclusion 31
12 ReIerences 32













SYW


Introduction

A small Ierry company which have 8 Ierries with Ierry ID (001 to 008) has just
purchased a computer Ior its new automated ticketing system. This Ierry ticketing
system will assign seats Ior each trips oI the 50-seater Ierry, which covers the route
Irom Langkawi to Penang and back daily. In this system, there are 10 seats is reserved
Ior business class passengers whereas the remaining 40 seats is economy class. The
system will maintain and control that a Ierry to accommodate 50 passengers as the
maximum.






















SYW


Acknowledgement

We would like to give our gratitude to all who has aided us in this journey to complete
Fundamental SoItware Development Assignment. First and Ioremost, many thanks go
to Mr. Yong Ket Wei Ior his support and invaluable advices on how to complete and
carry out the system properly. His eIIort in teaching us Java programming is most
appreciated.

Next, to Mr. SarIraz Nawaz Brohi who has taught us on hand Java programming by
using command prompt. All your eIIorts Ior us in the lab is learnt and applied into our
work. Not Iorgetting our parents and Iamily members who has continuously support
us and gave words oI encouragement.

Special thanks to Wong Chun Wai and Joshua Tan Ior giving us some technical
supports and guidelines on how to develop this Ierry ticketing system.

Last but not least, to all our Iriends and classmates who have given a helping hand to
help us understand our assignment better, to tell us where we did wrongly and even
provide advices on how to complete it better. Thank You.












SYW


orkload Matrix

Name orkload Percentage Signature

Cheong Qian Chen
TP023441

1) Design oI the program
2) Source Code
3) Sample Output
4) Assumptions
5) Future Enhancement
6) ReIerences



33.33


Ng Yung Hyun
TP019683

1) Cover Page
2) Acknowledgement
3) Source Code
4) Sample Output
5) Assumptions
6) Future Enhancement



33.33


Lim Pay Mun
TP019800

1) Introduction
2) Source Code
3) Sample Output
4) Assumptions
5) Future Enhancement



33.33








SYW


Design of the program - Screen Print

When the user execute this program, it will display main menu. In main menu, user
can choose P` to purchase the ticket, V` to view seating arrangement and Q` to quit
the system.

II the user key in P` as the input, submenu PURCHASING MODULE will display
Ior user to enter the option.


SYW



II the user key in B` as the input to purchase ticket Ior business class, the system will
prompt Ior destination to let user make an option.

SYW%



AIter the user key make an option Ior destination, the system will display 'Please
enter your name. The boarding ticket will be printed aIter the user key in the name
and main menu will be prompt again.







SYW%



II user want to view the seating arrangement aIter purchase the ticket. User can key in
the Ierry ID which can be Iound in the boarding ticket.

AIter key in the Ierry ID, user have to enter an option which is the destination and can
be Iound on the printed boarding ticket.
SYW



AIter the user key in the details, the seating arrangement Ior that Ierry will be
displayed in a tabular Iorm.

SYW



Lastly, user can exit the system by key in Q` as the input. AIter key in the correct
input, 'You have successIully exit the system will display.








SYW


Design of the program - Flowcharts







T F

T F



T F








T F






Start
Prompt Ior
mainMenu

Get the input
Input
P`?
Input
V`?
Input
Q`?
Display
'Invalid Input.
Please Retry.
Prompt Ior
Ferry ID

Get the input

Read the input
Input 1
or 2?
Display
'Invalid Input.
Please Retry.
Display
seatingChart

Prompt Ior
submenu
Stop
Display 'You
have successIully
exit the system
SYW





T F



T F

T F
T
F


















Input
B?
Input
E?
Input
M?
Display
'Invalid Input.
Please Retry.
Prompt Ior
destination

Get the input

Read the input
Prompt Ior name
Display 'Please
enter your name

Get the input
Read the input
Display the
boarding ticket
Display
'Invalid Input.
Please Retry.

Prompt Ior
mainMenu

SYW



T





T F






















Prompt Ior
destination

Get the input

Read the input
Prompt Ior name
Display 'Please
enter your name

Get the input
Read the input
Display the
boarding ticket
Display
'Invalid Input.
Please Retry.

Prompt Ior
mainMenu

SYW


Source Code of the Program in 1ava

import java.util.`;
public class Ferry
Scanner scan new Scanner(System.in);
boolean ubl true; boolean ubp true; boolean uel true; boolean uep
true;
int bl 0; int bp 0; int el 0; int ep 0;
int fbl 1; int fbp 1; int fel 1; int fep 1;
double timeBL 10.0; double timeEL 10.0; double timeBP 10.3; double
timeEP 10.3;
final int maxB 10;
final int maxE 40;
final int maxF 8;
String string, source, destination;
String ampm "am";
public static void main(String] args)
Ferry fts new Ferry();
fts.mainMenu();
]
public void mainMenu()
System.out.println("FERRY TICKETING SYSTEM");
System.out.println("P - to Purchase Ticket");
System.out.println("V - to View Seating Arrangement");
System.out.println("Q - to Quit the system");
System.out.print("Please enter your option: ");
string scan.next();
if (string.equals("P"))
submenu();
]
SYW


else if (string.equals("V"))
seatingChart();
]
else if (string.equals("Q"))
System.out.println("\nYou have succesfully exit the system.");
]
else
System.out.println("\nInvalid input. Please retry.\n");
mainMenu();
]
]
public void submenu()
System.out.println("\nPURCHASING MODULE");
if (ubl true [[ ubp true)
System.out.println("B - to purchase ticket for Business class");
]
else
System.out.println("B - to purchase ticket for Business class of
another time");
]
if (uel true [[ uep true)
System.out.println("E - to purchase ticket for Economy class");
]
else
System.out.println("E - to purchase ticket for Economy class of
another time");
]
System.out.println("M - to return to Main Menu");
System.out.print("Please enter your option: ");
string scan.next();
SYW


double] array new double4];
if (string.equals("B"))
source();
if (string.equals("1"))
array chosen(bl, fbl, maxB, timeBL, ubl, "Business",
"Langkawi", "Penang");
bl (int) array0];
fbl (int) array1];
timeBL array3];
if (array2] 0)
ubl false;
]
else
ubl true;
]
if (ubl true)
mainMenu();
]
else
submenu();
]
]
else
array chosen(bp, fbp, maxB, timeBP, ubp, "Business",
"Penang", "Langkawi");
bp (int) array0];
fbp (int) array1];
timeBP array3];
if (array2] 0)
ubp false;
SYW
%


]
else
ubp true;
]
if (ubp true)
mainMenu();
]
else
submenu();
]
]
]
else if (string.equals("E"))
source();
if (string.equals("1"))
array chosen(el, fel, maxE, timeEL, uel, "Economy",
"Langkawi", "Penang");
el (int) array0];
fel (int) array1];
timeEL array3];
if (array2] 0)
uel false;
]
else
uel true;
]
if (uel true)
mainMenu();
]
else
SYW
%


submenu();
]
]
else
array chosen(ep, fep, maxE, timeEP, uep, "Economy",
"Penang", "Langkawi");
ep (int) array0];
fep (int) array1];
timeEP array3];
if (array2] 0)
uep false;
]
else
uep true;
]
if (uep true)
mainMenu();
]
else
submenu();
]
]
]
else if (string.equals("M"))
mainMenu();
]
else
System.out.println("\nInvalid input. Please retry.\n");
submenu();
]
SYW


]
public void customer(int seat, int ferry, double time, boolean available,
String classType, String source, String destination)
System.out.print("Please enter your name: ");
string scan.next();
System.out.println("\nBoarding Ticket:");
System.out.println("Name: " + string);
System.out.println(classType + " class seat number: " + seat);
System.out.println("Time of departure: " + time + "0" + ampm(time));
System.out.println("Source: " + source);
System.out.println("Destination: " + destination);
System.out.println("Ferry ID: 00" + ferry + "\n");
]
public void source()
System.out.println("\nYou are travelling from: ");
System.out.println("1 - Langkawi");
System.out.println("2 - Penang");
System.out.print("Please enter your option: ");
string scan.next();
if (string.equals("1"))
source "Langkawi";
destination "Penang";
]
else if (string.equals("2"))
source "Penang";
destination "Langkawi";
]
else
System.out.println("\nInvalid input. Please retry.\n");
source();
SYW


]
]
public double] chosen(int seat, int ferry, int maxSeat, double time, boolean
available, String classType, String source, String destination)
double] combination new double4];
int bool 0;
if (seat < maxSeat && ferry < maxF && available true)
System.out.println("\nYou have chosen to purchase: " + classType +
" class ferry ticket");
seat++;
if (seat < maxSeat)
]
else
seat 1;
ferry++;
]
if (ferry < maxF)
customer(seat, ferry, time, available, classType, source,
destination);
]
else
System.out.println("\ne are sorry to inform you that all " +
classType + " class ferry tickets for this time have been sold out.");
System.out.println("Please reconsider with the following
options.");
available false;
]
]
else
System.out.println("\nYou have chosen to purchase: " + classType +
SYW


" class ferry ticket of another time");
System.out.println("Next trip leaves in one hour.");
seat 1;
ferry 1;
if ((time < 12.0 && time > 10.0) [[ (time < 4.0 && time > 1.0))
time time + 1.0;
]
else if (time 12.0 [[ time 12.3)
time time - 11.0;
]
else if (time 4.0 [[ time 4.3)
time time + 6.0;
]
available true;
customer(seat, ferry, time, available, classType, source, destination);
]
if (available true)
bool 1;
]
else
bool 0;
]
combination0] seat;
combination1] ferry;
combination2] bool;
combination3] time;
return combination;
]
public String ampm(double time)
if (time < 12.0 && time > 10.0)
SYW


return "am";
]
else
return "pm";
]
]
public void seatingChart()
int seatsB, seatsE, ferryID;
System.out.print("Ferry ID: ");
ferryID scan.nextInt();
if (ferryID < maxF)
source();
if (source.equals("Langkawi"))
if (ferryID < fbl)
seatsB maxB;
]
else if (ferryID fbl)
seatsB bl;
]
else
seatsB 0;
]
if (ferryID < fel)
seatsE maxE;
]
else if (ferryID fel)
seatsE el;
]
else
seatsE 0;
SYW


]
]
else
if (ferryID < fbp)
seatsB maxB;
]
else if (ferryID fbp)
seatsB bp;
]
else
seatsB 0;
]
if (ferryID < fep)
seatsE maxE;
]
else if (ferryID fep)
seatsE ep;
]
else
seatsE 0;
]
]
printStarLine(40);
System.out.print("\n` Ferry ID : 00" + ferryID + " Date : 19 Sept
2005 `");
printStarLine(40);
System.out.print("\n` BUSINESS CLASS
`");
printStarLine(40);
int rows 2;
SYW


for (int i 0; i < rows; i++)
seatsB printNumberLine(seatsB);
printStarLine(40);
]
System.out.print("\n` ECONOMY CLASS
`");
printStarLine(40);
rows 8;
for (int i 0; i < rows; i++)
seatsE printNumberLine(seatsE);
printStarLine(40);
]
System.out.println("\n");
mainMenu();
]
]
public void printStarLine(int num)
System.out.print("\n`");
for (int i 0; i < num; i++)
System.out.print("`");
]
]
public int printNumberLine(int seats)
int rowSeats 5;
System.out.print("\n`");
if (seats > rowSeats)
for (int i 0; i < rowSeats; i++)
System.out.print(" 1 `");
]
seats seats - rowSeats;
SYW


]
else
for (int i 0; i < seats; i++)
System.out.print(" 1 `");
]
for (int i 0; i < (rowSeats - seats); i++)
System.out.print(" 0 `");
]
seats 0;
]
return seats;
]
]

















SYW


Sample Outputs with explanation
Main Menu
When the program is executed, a main menu oI Ferry Ticketing System will prompt
and displayed. User can key in inputs P` Purchase Ticket, V` View Seating
Arrangement or Q` Quit the System whereas iI the user key in other input, the
system will display 'Invalid Input. Please retry. and then will display the main menu
again.

Input P`
II the user key in P` as the input, the system will prompt and display 'Purchasing
Module which consists inputs B` Purchase Ticket Ior Business Class, E` -
Purchase Ticket Ior Economy Class or M` Return to Main Menu. The system will
always display 'Invalid Input. Please retry. Ior this whole system iI user key in other
input.

Input B`
II the user key in B` as the input, the system will display and let user to key in
options which is 1` - Langkawi or 2` Penang. The system will again display
'Invalid Input. Please retry. iI user key in other input.

II user decided to choose 1` Langkawi as the input, the system will display 'Please
enter your name then the system will automatic assign and print out a Ierry ticket
with some inIormation such as name, type oI class with seat number, time oI
departure, source, destination and Ierry ID aIter user key in the name.

Input V`
II the user key in V` as the input, the system will prompt and user must key in the
Ierry ID to proceed. II user key in 001` as the Ierry ID input, the system will then
prompt again to let user choose Irom the options. II the input value is true, then the
system will display the seating arrangement Ior that Ierry in a tabular Iorm.
SYW
%


Another sample output oI this system is iI the business class seats Ior Iirst Ierry are
Iull, the system will continue assign the seat Ior next purchase to second Ierry. When
all oI the business class seats are Iull, the system will display 'We are sorry to inIorm
you that all business class Ierry tickets Ior this time have been sold out. Please
reconsider with the Iollowing options whereas Ior economy class Ierry tickets, the
system will display 'We are sorry to inIorm you that all economy class Ierry tickets
Ior this time have been sold out. Please reconsider with the Iollowing options

II the user still wants to purchase the business ticket, the system will display 'You
have chosen to purchase business class Ierry ticket oI another time. Next trip leaves
in one hour. while iI the user still wants to purchase the economy ticket even all the
Ierry seats are Iull now, then the system will assign a seat and display 'You have
chosen to purchase economy class Ierry ticket oI another time. Next trip leaves in one
hour.
















SYW
%


Assumptions

Assume that iI a customer wants to purchase the ticket at 10a.m. but only want to
depart at 3pm. The system cannot generate and print a Ierry ticket Ior 3p.m. which
means the customer cannot choose the time to depart. Customer also cannot choose
which Ierry to take because the systems will automatic assign the time and Ierry ID
when the ticket is purchased.

Other than that, some input in this problem required capital letter. For example, iI user
key in P` as the input to purchase ticket, the user must key in capital P`. II the user
key in p` as the input, the system cannot read the input and 'Invalid input. Please
retry will display.


















SYW


Future Enhancement

In this Java program, there are some Ieatures is not perIect and good enough and we
believe that it can be better. We believed that we should edit the program that enables
user to choose time oI departure.

Furthermore, we also suggest that iI the system can let the user to purchase ticket Ior
the coming Iew days. This will deIinitely bring convenient to the customers. Other
than that, additional Ieatures such as choose seat Ior Ierry can be added to this system
to make it more Iunctional.




















SYW


Conclusion

The system achieved the basic requirements oI a Ierry ticketing system. The system
can provide some necessary details Ior the Ierry ticket. The system will maintain and
prevent a Ierry will more than 50 passengers.

In conclusion, we believe that this system is good enough Ior a small Ierry company
Ior its automated ticketing system.






















SYW


References

Source Code
1) Java Notes (2010), 'Boolean |Online| available Irom:
http://leepoint.net/notes-java/data/basictypes/26boolean.html |Assessed on 9
November 2010|.

2) The Big Moose Saloon (2010), 'All possible combinations oI the elements in
the string array |Online| available Irom:
http://www.coderanch.com/t/381411/java/java/All-possible-combinations-ele
ments-string |Assessed on 9 November 2010|.

3) Java
TM
2 PlatIorm Std. Ed. v1.3.1 (2010), 'Class Double |Online| available
Irom:
http://www.iIs.tuwien.ac.at/iIs/lehre/eprog/javadoc/jdk/docs/api/java/lang/Dou
ble.html |Assessed on 9 November 2010|.

Flow Charts
1) Lesley Anne Robertson, Simple Program Design 5th Edition 'A Step-By-Step
Approach, Chapter 1 to Chapter 7 and Appendix 1.

Das könnte Ihnen auch gefallen