You are on page 1of 2

Page 1 of 2 Pages SUBJECT: APPLICATIONS DEVELOPMENT PRACTICE II

APPLICATIONS DEVELOPMENT PRACTICE II (ADP262S) Date: 24 April 2023

The Granger Bay Hotel School, located at Mouille Point in Cape Town, is part of the Faculty
of Business Management Sciences of the Cape Peninsula University of Technology. A
restaurant, which is open to the public, is also part of this facility. The restaurant has
operated since the inception of the Hotel school in 1989 and is staffed by our students
training under professional supervision. Located at the water’s edge of the Atlantic Ocean
with breath-taking views of Robben Island, the restaurant offers fine cuisine (Halaal-
friendly) in an elegant and peaceful setting.

Make a copy of your previous Netbeans project application and then make the
modifications to write values to a serialized file. A ser file cannot be opened for appending
so you will have to change some of the logic.

Step 1: Create a Java class called FileHandler, which includes these additional methods:
a) openOutputSerFile(String filename) – opens/creates a ser file for writing
a) processSerFile(Customer obj) - writes a string to the file
b) closeOutputSerFile() – closes the file
It may be useful to declare these methods as static.

Step 2: Create a Java worker class using the Customer UML below:

Customer
title: String
firstName: String
lastName: String
smoker: boolean
staff: boolean (CPUT staff members receive a discount)
constructors…
getters…
setters…
writeToFile: boolean
writeToSerFile: boolean

The method writeToSerFile calls methods from the FileHandler class to:
b) open a ser file called OutputSerCustomers for writing.
c) write a ser object to the file
Page 2 of 2 Pages SUBJECT: APPLICATIONS DEVELOPMENT PRACTICE II

Step 3: Write a Java program to produce a GUI, similar to the one shown below. The
only difference to the previous version is the addition of a Close File button.

Close file

Close file

Step 4:
If the user clicks on the Save to File button, and the textfields are empty or they contain
non-alphabetic characters, then an error message must be displayed in a JOptionPane
dialog box. The textfields must then be cleared and the cursor placed in one of the
textfields. Once the user has entered valid values then they must be used to instantiate
and initialize a Customer object that must be written to the serialized file.

Step 5:
If the user clicks on the Close File button then the ser file is closed.

Additional instructions:
 Make use of good programming practices:
o modular programming techniques. One method should not do more than one
logical operation.
o Efficient algorithms and code
o Good user interface design (experiment with fonts, colours, layouts, etc)
 A submitted solution application that does not compile, or does not produce any
output will receive ZERO marks.
 Once completed, submit a zipped Netbeans project to the link on BB.
 Failure to follow instructions will result in penalties.

You might also like