Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

IS200

IS Software Foundations

Lab Test 2

General Instructions:

Desk Num:

You cannot
-
-

[30 marks]

Refer to any material or use your own laptop


Connect to the network (no Internet will be available)

You are provided with the following on your workstation running Windows XP:
-
-
-
-
-
-

Your IS200 lecture slides are in c:\labtest\Lecture Slides


Standard Java API documentation (shortcut on desktop)
Java API documentation for the classes required for this test is in c:\labtest\api\
Java bytecode files (.class files) required for this test are in c:\labtest\answers\<your email ID>\Q<num>
Java Development Kit 7 (run it from DOS)
Notepad++ (shortcut on desktop)

Failure to do the following will attract a penalty of 20% of your score for that question.
You MUST:
a)

Include your name as author in the comments of all your submitted source files. For example, if your registered name is
"Sotong TAN" and email ID is sotong.tan.2011, include the following block of comments at the beginning of each source
file (.java) you write.
/*
* Author: Sotong TAN
* Email: sotong.tan.2012
*/

b)

Follow standard Java coding conventions (e.g. naming of getter and setter methods, choice of identifier names for classes,
methods and variables) as well as indent your code correctly.

c)

Ensure that all your Java code can compile without compilation errors. They must compile with any test class(es) that are
provided. (You may wish to comment out the parts in your code, which cause compilation errors. Commented code will
not be marked.)

Failure to submit your answers correctly will result in a zero score.



Instructions on how to submit your answers:

a) When the PC starts, a program will run to prompt you for your email ID. This program creates the following folders on the
PC:

C:\labtest\answers\<your email ID>\Q1-2

C:\labtest\answers\<your email ID>\Q3


Please inform the invigilator if you cannot find these folders.
b)

c)

Place your answers (your .java files) for each question into the respective folders. E.g. Your answer for Q3 should be in
C:\labtest\answers\<your email ID>\Q3 etc. Only the .java files in these folders will be marked. All other files will be
ignored.
At the end of the test, the contents of c:\labtest\answers\ will be automatically copied to a central server. Everything else
on the PC will not be marked.

2014-15/Lab Test 2/

Page 1 of 7

IS200 IS Software Foundations

Question 1

[ 10 marks ]

You are given the source code inside the folder Q1-2\.
You are given the API for BrosDate inside the folder <your student ID>\API\.

Note:
You should be making minimal changes to the application to make it work! Marks will be deducted for un-
necessary modification or rewriting of the whole functionality.
There are 2 changes to the project.
The application is changed to a self-service kiosk. Students will need to login to the application and book the facility
themselves.
The functionality Cancel my Booking is added to the application. To support this functionality, a new attribute
called cancelled is added to the Booking class.
BrosDate class has computeDateByMinute and computeDateByHour instead of the original computeDate
method.

A. [4.5 marks] Try compiling the code using the command javac *.java (or use compile.bat). You will see a
number of compilation errors. Identify and fix the compilation errors.


B. [1.5 marks] During login, if the student enters the incorrect username the first time round, he will never be able to
log into the system. Note: "wronguser" is a invalid username.
Enter username> wronguser
Enter password> 1234
invalid username/password
The username and password is
Enter username> fergie
entered correctly in the second try.
Enter password> 1234
invalid username/password
Enter username>


2014-15/Lab Test 2/

Page 2 of 7

IS200 IS Software Foundations


C.

[2 marks] In List all Bookings by a student, the application list only 1 booking even though the student has
multiple bookings.
== BROS :: Main Menu ==
1. List all Students
2. List all Facilities
3. List all Bookings
4. List all Bookings by a student
tina has 2 bookings
5. Book a Facility
1. Facility F004 on 8 A pr 2015 3pm 4pm
6. Cancel my Booking
2. Facility F004 on 9 Apr 2015 3pm 4pm
7. Logout
8. Quit Application
Enter your choice > 4
Enter student ID > tina

== BROS :: Bookings by fergie ==

Facility
Booking Date/Time Start Date/Time
Duration
Room 2-4
07/04/2015 16:24 07/04/2015 15:15 1

D. [2 marks] The application has a bug. It allows the student to repeatedly cancel a booking.
Note: tinas eDollar balance increases every time she cancels it.
Enter username>tina
Enter password>1234

== BROS :: Main Menu ==
1. List all Students
2. List all Facilities
3. List all Bookings
4. List all Bookings by a student
5. Book a Facility
6. Cancel Booking
7. Logout
8. Quit Application
Enter your choice >4
Enter student ID >tina

== BROS :: Bookings by tina ==

Facility
Booking Date/Time Start Date/Time
Duration
Room 2-4
03/04/2015 16:05 08/04/2015 15:00 1
Room 2-4
03/04/2015 16:05 09/04/2015 15:00 1

== BROS :: Main Menu ==
1. List all Students
2. List all Facilities
3. List all Bookings
4. List all Bookings by a student
5. Book a Facility
6. Cancel Booking
7. Logout
8. Quit Application
Enter your choice >6




2014-15/Lab Test 2/

Page 3 of 7

IS200 IS Software Foundations


== BROS :: Cancel my Booking ==

Enter a facility ID > F004
You have successfully cancelled this facility.
You have 24 E$ left.

== BROS :: Main Menu ==
1. List all Students
2. List all Facilities
3. List all Bookings
4. List all Bookings by a student
5. Book a Facility
6. Cancel Booking
7. Logout
8. Quit Application
Enter your choice >6

== BROS :: Cancel my Booking ==

Enter a facility ID > F004
You have successfully cancelled this facility.
You have 28 E$ left.

2014-15/Lab Test 2/

Note that the E$ is increased from 24


to 28. 2 bookings each of 1 duration is
cancelled.

Page 4 of 7

IS200 IS Software Foundations

Question 2

[ 10 marks ]

You are given the source code inside the folder your thumb drive:\<your student ID>\Q1-2\.
You are given the API for BrosDate inside the folder your thumb drive:\<your student ID>\api\.

A. [ 5 marks ] A user will have to check in within his booking timing to utilize his booking. Implement the check in
functionality.
Hint:
i.
Implement BrosMenus processCheckIn to include the necessary user interface logic & calling the
necessary manager classes (e.g. BookingManager)
ii.
Implement BookingManagers retrieveCurrentBookings to get the list of active bookings(current
time is after bookings start time, and current time is before bookings end time) by the logged in user that
is currently active.
iii.
The Bookings checkedIn attribute is set to true when the user checks in.

Below is the sample output for user fergie who has logged in on 7 Apr 4:35pm.

== BROS :: Main Menu ==
1. List all Students
2. List all Facilities
3. List all Bookings
4. List all Bookings by a student
5. Book a Facility
6. Cancel my Booking
7. Check In
8. Logout
9. Quit Application
Enter your choice >7

== BROS :: Check In ==
Facility Booking Date/Time Start Date/Time
Duration
1. Room 2-3 07/04/2015 15:41 07/04/2015 15:00 2
2. Room 2-4 07/04/2015 15:41 07/04/2015 16:00 2
Enter your choice >1
The list of active current bookings will
You have checked in successfully.
differ depending on the access time

== BROS :: Main Menu ==
1. List all Students
2. List all Facilities
3. List all Bookings
4. List all Bookings by a student
5. Book a Facility
6. Cancel my Booking
7. Check In
8. Logout
9. Quit Application
Enter your choice >7

== BROS :: Check In ==
No booking available
Press Enter to return to Main Menu

2014-15/Lab Test 2/

Page 5 of 7

IS200 IS Software Foundations


B.

[ 5 marks ] Implemement the overriding functionality. A user can book an existing booking(i.e. book it) if the
student (of the original booking) did not check in within 15 minutes of his booking start time to utilize his booking.
You should
i.
cancel the original booking (without refunding)
ii.
create a new booking
Complete the method canOverride in Booking class and use it to solve this question!


Below is the sample output for user tina who has logged in on 7 Apr 3:35pm, and override fergies booking on F004.
== BROS :: Book a Facility ==
Enter a facility ID > F003
Fergie has a booking from 5pm 7pm
Enter start date (DD/MM/YYYY) > 07/04/2015
on facilty F003 (cant be overridden at
Enter start time (HH:00) > 16:00
3:35pm)
Enter number of hours > 2
Booking overlaps with another booking. Please try again.

== BROS :: Main Menu ==
1. List all Students
2. List all Facilities
3. List all Bookings
4. List all Bookings by a student
5. Book a Facility
6. Cancel Booking
7. Check in
8. Logout
9. Quit Application
Enter your choice >5

== BROS :: Book a Facility ==
Enter a facility ID > F003
Enter start date (DD/MM/YYYY) > 07/04/2015
Enter start time (HH:00) > 16:00
Enter number of hours > 1
You have successfully booked this facility.
You have 18 E$ left.

Question 3

[ 10 marks ]

Examine all the source files provided in the Q3 folder. Each of these:
Utility1.java,

[ 3 marks ]
Utility2.java, and

[ 3 marks ]
Utility3.java,

[ 3 marks ]

contains skeletal code. Based on the instructions in the comments, implement each method. You are also provided with
several class files (e.g. Product.class, Shop.class, Tenant.class, ShoppingCenter.class); refer to the API documentation in
the api folder for how to use them.

These classes contain test code (in the main method) to help you determine if you have written your methods correctly.
Read and understand how the test code works so that you can use it to your advantage.

Notes:
1. Do NOT change the method signatures.
2. It is OK for the ordering of the output to be slightly different as long as the values match.
2014-15/Lab Test 2/

Page 6 of 7

IS200 IS Software Foundations

Appendix A

Users
Username
tina
fergie

password
1234
1234


Bookings
Username
tina
fergie

Facility ID
F004
F003
F004
F003
F004
F003

Booking Date (start time end time)


08/04/2015 3pm 4pm
09/04/2015 3pm 4pm
07/04/2015 3pm 5pm
07/04/2015 4pm 6pm
07/04/2015 5pm 7pm
07/04/2015 6pm 8pm
07/04/2015 7pm 9pm

2014-15/Lab Test 2/

Page 7 of 7

You might also like