You are on page 1of 37

OODJ Individual Assignment(CT038-3-2) 2014

1



Table of Contents

1.0 Introduction ................................................................................................................................. 2
2.0 UML Diagrams ........................................................................................................................... 3
i. Use Case Diagram ....................................................................................................................... 3
ii. Use case specifications............................................................................................................ 4
iii. Activity diagram ................................................................................................................... 11
iv. Class Diagram ....................................................................................................................... 16
3.0 Object Oriented Programming .................................................................................................. 18
i. What is object oriented programming? ..................................................................................... 18
ii. Object oriented concepts ........................................................................................................... 20
(i) Abstract classes ..................................................................................................................... 20
(ii) Polymorphism ................................................................................................................... 21
(iii) Encapsulation ........................................................................................................................ 23
(iv) Serialization .......................................................................................................................... 25
4.0 Sample outputs .......................................................................................................................... 28
i. Login Page ................................................................................................................................ 28
ii. Register new user ...................................................................................................................... 29
iii. Register New Customer Profile ............................................................................................ 30
iv. Update booking ..................................................................................................................... 31
v. Update Room Status ................................................................................................................. 32
5.0 Assumption .............................................................................................................................. 33
6.0 Conclusion ............................................................................................................................... 34
7.0 References ................................................................................................................................. 35




OODJ Individual Assignment(CT038-3-2) 2014

2


1.0 Introduction

This assignment is about creating a system called Hotel Room Management System
where this system is created to maintain customers booking details for a hotel. The main
purpose of this system is to stimulate a hotel room management system for a small hotel with
only three floors, each floor with 10 rooms, and each room will be charged RM100 per night.
This system will be used by administrator, reservation staff, front desk staff and cleaning
staff. Each user of the system has its own user name and password and these users will be
able to use the system depending on their priority access. It means different users are able to
use the system for specific purpose depending on the priority assigned to them.
I would like to thank my lecturer Mr. Kau Guan Kiat who guided us on completing
this assignment as the requirement set upon completing this assignment is complication and it
takes time to complete this assignment. I did research on what is object oriented and types of
object oriented available. After careful research, I am able to apply some of the concepts in
my assignment.





OODJ Individual Assignment(CT038-3-2) 2014

3


2.0 UML Diagrams
i. Use Case Diagram
OODJ Individual Assignment(CT038-3-2) 2014

4


Based on the Hotel Room Management System, there are 4 users in the system. The users
comprises of administrators, reservation staff, front desk staff and cleaning staff. There are 7
cases which are performed by the actors. Each of their actors holds their own priority
whereby they limited to use own cases as what can be seen above.

ii. Use case specifications

Login
Use Case Name : Login
Scenario : Staffs login into the system
Triggering Event : When staffs select login option
Brief
Description :
This function will allow staffs to login into the system and manage
customer booking details
Actors : Administrator, Reservation staff, Front desk staff and Cleaning staff
Preconditions : Only the authorize user can access the system with a valid username and
password.
Post conditions : Valid user profile is to be accessed
Flow of Events : Actor System
1. Select Login Option


1.1 Prompt User for username and
password.
1.2 Continue access if valid, try
again if invalid.

OODJ Individual Assignment(CT038-3-2) 2014

5



Register User









Use Case Name : Register user
Scenario : Register new user into the system
Triggering Event : When User select register customer option
Brief
Description :
This function will allow user to add new user into the system
Actors : Administrator
Preconditions : Must be an authorized staff to add new user
Post conditions : User details are added into the system
Flow of Events : Actor System
2. Select register user option


1
2
3
2.1 Prompt user to add username,
and password

2.2 Save the information into
database
OODJ Individual Assignment(CT038-3-2) 2014

6



Update customer details







Use Case Name : Update customer details
Scenario : Update customer details from the system
Triggering Event : When User select update customer details option
Brief
Description :
This function will allow user to add, edit, delete and update all users
information from the system
Actors : Administrator, Reservation staff and Front desk staff
Preconditions : Must be in the System only can access the function
Post conditions : Changes made into the system
Flow of Events : Actor System
3. Select update customer
details
1.
2.
3.
4.
5.
6.
7.
3.1 Prompt user to add, edit, delete
or update customer
information
3.2 Updates data will be saved in
database
OODJ Individual Assignment(CT038-3-2) 2014

7




Update Booking



Use Case Name :

Update Booking
Scenario : Update booking information for customers
Triggering Event : When User select update booking option
Brief
Description :
This function will allow user to do check in and check out for customers
Actors : Reservation staff and front desk staff
Preconditions : Must be in the System only can access the function
Post conditions : Save updates
Flow of Events : Actor System
4. Select Update booking 4.1 Update booking status of the
customer
4.2 Manage check in and check
out of the customer
4.3 Save changes
OODJ Individual Assignment(CT038-3-2) 2014

8


Check In













Use Case Name : Check in
Scenario : Staff manage check in for the customer into the system
Triggering Event : When staff select check in option
Brief
Description :
This function will allow staff to check in for the customer who has
reserved the room for the particular days into the system
Actors : Front desk staff
Preconditions : Only the authorize user can access the system with a valid username
and password.
Post conditions : Check in is successful
Flow of Events : Actor System
5. Select check in Option


5.1 Prompt User to select check
in for the customer
5.2 Check in successful
OODJ Individual Assignment(CT038-3-2) 2014

9


Check Out













Use Case Name : Check out
Scenario : Staff check out for customer from the system
Triggering Event : When staff select check out option
Brief
Description :
This function will allow staff to check out for the customer
Actors : Front desk staff
Preconditions : Only the authorize user can access the system with a valid username and
password.
Post conditions : Check out is successful
Flow of Events : Actor System
6. Select check out Option


6.1 Prompt User to select check
out for customer
6.2 Check out is successful
OODJ Individual Assignment(CT038-3-2) 2014

10


Update room status







Use Case Name : Update room status
Scenario : Update room status into the system
Triggering Event : When User select update room status option
Brief
Description :
This function will allow user to change the room status from To be
cleaned to cleaned or vice versa
Actors : Cleaning staff
Preconditions : Must be in the System only can access the function
Post conditions : Changes of room status will be saved in the system
Flow of Events : Actor System
7. Select update room status
Option


8.
9.
10.
11.
7.1 Prompt User to update the
room status
7.2 Save the changes into the
database.
OODJ Individual Assignment(CT038-3-2) 2014

11


iii. Activity diagram
User Login Activity Diagram





OODJ Individual Assignment(CT038-3-2) 2014

12


Administrator Activity Diagram

OODJ Individual Assignment(CT038-3-2) 2014

13



Reservation Staff Activity Diagram

OODJ Individual Assignment(CT038-3-2) 2014

14



Front Desk Staff Activity Diagram

OODJ Individual Assignment(CT038-3-2) 2014

15



Cleaning Staff Activity Diagram



OODJ Individual Assignment(CT038-3-2) 2014

16


iv. Class Diagram




Figure: 1


OODJ Individual Assignment(CT038-3-2) 2014

17


Class diagram



Figure: 2
OODJ Individual Assignment(CT038-3-2) 2014

18


3.0 Object Oriented Programming

i. What is object oriented programming?
Object oriented programming (OOP) represents a programming language model
ordered around objects rather than "actions" and data rather than logic. In object oriented
programming, programmers need to find the object which are entities which have the
behaviors that contains information and able to communicate each other. Basically, a
program has been viewed as a logical procedure that takes input data, processes it, and
produces output data
In addition, the programming challenge was depends on how to write the logic, not
how to define the data whereby object-oriented programming takes the view that what we
really care about are the objects we want to manipulate rather than the logic required to
manipulate them. Examples of objects range from human beings (described by name,
address, and so forth) to buildings and floors (whose properties can be described and
managed) down to the little widgets on a computer desktop (such as buttons and scroll bars).
(Searchsoa.techtarget.com, 2014)
There are many terms related to object oriented which are:
a) Object is a bundle of software of similar state or variables and behavior or related
methods. An object is also known as instance which refers to particular object. The
variable of object will be instances variables as they contain state for specific object
or instance.

b) Class is a type of object which is a blueprint or plan that describe the details of an
object. A class is the blueprint from which the individual objects are created. Class is
composed of three things such as name, attributes, and operations and also known as a
thing which consists of pattern and mechanism creating items based on pattern.
(Codeproject.com, 2013)



OODJ Individual Assignment(CT038-3-2) 2014

19



There are several types of classes which are:

(i) Meta classes is a class whose instances themselves are classes whereby it
means when the user uses the instances for the creation mechanism in a meta
class and the instance created will be a class. The instance created in this class
can be used again to create instances where it cant be told exactly whether
these instances may or may not be themselves be classes.
(ii) Parameterized class is a concept which is almost as same as meta class. It is a
template for a class where specific items have been recognized as being
requested to create non-parameterized classes based on the template. When
put into use, the parameterized class can be viewed as a fill in the blanks
version of a class and programmer cant use the instances creation
mechanisms of a parameterized class.
(iii) Non-class instance is an instance of a class but it itself is not a class.

c) Exception is an event that causes suspensions of normal applications execution or in
other word, it is a set of information directly relating to the event that caused
suspensions of normal application execution.
OODJ Individual Assignment(CT038-3-2) 2014

20



ii. Object oriented concepts

(i) Abstract classes

Abstract classes are classes which embodies incomplete coherent and cohesive but makes
these characteristics available to their specialization through inheritance. If happen to be we
couldnt create instance of abstract classes, we most certainly would make their individual
characteristics available to more specialized classes via inheritance. An abstract class exists
only to express common properties of all its subclasses and class without abstract is known as
concrete.
Programmer will be able to create objects belongs to the concrete class but not an
abstract class. A variable type which is an abstract class can only be referred to objects
belonging to concrete subclasses of the abstract class. An example of abstract class as stated
below:

public abstract class Shape
{
Color color; / / color of shape .
void setColor(Color newColor)
{ / / method to change the color of the shape
color = newColor; / / change value of instance variable
redraw(); / / redraw shape , which w ill appear in new color
}

abstract void redraw();
/ / abstract methodmust be defined in concrete subclasses
. . . / / more instance variables and methods
} / / end of class Shape

OODJ Individual Assignment(CT038-3-2) 2014

21


Once programmer have declared the class to be abstract, it automatically becomes illegal
to try to create actual objects of type Shape and the computer will generate report stating that
there is a syntax error found if the programmer does so.

(ii) Polymorphism

Polymorphism is the ability for a single object reference to refer to more than a single
concrete type or it is a programming language ability to process objects differently depending
on their data types or class. The benefit of it is that the introduction of a new type does not
force widespread code changes.

In polymorphism, there are three distinct forms which are:
(a) Method overloading
- A method has a unique name within its class but the method might have the same
name as other methods
(b) Method overriding through inheritance
- When a class is extended, we can change the behavior of a method of the parent
class.
(c) Method overriding through the Java interface
Lets look at the image above for an example where there are three shapes displayed
which are rectangles, ovals and Roundrects. These three classes would have a common
superclass which is Shape to represent features which all three shapes have in common. The
Shape class can include instance variables to represent color, position and size of a shape. It
would even include instance methods for changing the color, position and size of the shape.
Lets look at the code below:
OODJ Individual Assignment(CT038-3-2) 2014

22


class Shape {
Color color; // Color of the shape. ( Recall that class Color
/ / is defined in package java. awt . Assume
/ / that this class has been imported . )
void setColor(Color newColor) {
/ / Method to change the color of the shape .
color = newColor; / / change value o f instance variable
redraw(); / / redraw shape , which will appear in new color
}
void redraw() {
/ / method for drawing the shape
? ? ? / / what commands should go here?
}
. . . / / more instance variables and methods
} / / end of class Shape

From the given code, we are able to spot a problem with redraw() where each shape is
draw distinctly. The method setColor() can be called for any type of shape. The computer
tends to execute redraw() by asking the shape to redraw itself. Every shape object knows
what it has to do to redraw itself.




OODJ Individual Assignment(CT038-3-2) 2014

23


(iii) Encapsulation

Encapsulation is the technique of creating up a field in a class private and allowing access
to the fields via public methods. Lets say if in Java, a field is declared to be private, it cannot
be accessed by anyone outside the class by hiding fields within the class. That is the reason
why encapsulation is known as the data hiding.
The data hiding is the strength of objects to protect variables from external access. That
variable checked as private can only be seen on modified through the use of public accessor
and mutator methods which allows validity checking to be run at time. The access to other
variables is allowed but with tight control on how it is done. The methods can also be used
hidden from programmer and for the people who are made visible externally can only be
called by using object front door.
The benefit of encapsulation is the ability to modify the created code without breaking the
code of others who use our code. With this feature, encapsulation gives maintainability,
flexibility and extensibility to our code.
Image below taken from: (Tutorialspoint.com, 2014)
/* File name : EncapTest.java */
public class EncapTest{

private String name;
private String idNum;
private int age;

public int getAge(){
return age;
}

public String getName(){
return name;
}

OODJ Individual Assignment(CT038-3-2) 2014

24


public String getIdNum(){
return idNum;
}

public void setAge( int newAge){
age = newAge;
}

public void setName(String newName){
name = newName;
}

public void setIdNum( String newId){
idNum = newId;
}
}
OODJ Individual Assignment(CT038-3-2) 2014

25



(iv) Serialization

Serialization is the process of writing the state of an object to a byte stream. It can be used
to save variables or to communicate through network connections. Another definition is it is
the process of converting a set of objects instances which contains references to each other
into a linear stream of bytes which later can be sent through a socket which can be stored to a
file or manipulating it as a stream of data. It is the mechanism used by remote method
invocation (RMI) to pass objects between java virtual machines (JVM) by either as
arguments in a method invocation from client to server or as return values from a method
invocation.
When implementing the serialization codes, the serializable interface relies on the Java
runtime default mechanism to save an object's state. The writing of an object is done via the
writeObject() method in the ObjectOutputStream class or the ObjectOutput interface. The
writing of a primitive value may be done through the appropriate write<datatype>() method.
For the reading serialized object, it is accomplished using the readObject() method of the
ObjectInputStream class and primitives may be read using the various read<datatype>()
methods. Lets look at an example of serialization:

The above image show a banking application where a client is making a withdrawal and
the runtime structure is shown above. The instance of Money being passed to server means
that the server is able to call public methods on the instance of Money. This can be done by
making the Money into a server. For instance, lets say the client sends following two pieces
of information whenever it passes and instance of an argument which are the type of
instances (Money) and a unique identifier for the object such as address of the instance in
memory.
OODJ Individual Assignment(CT038-3-2) 2014

26


Below is an example of code for serialization taken from: (Google+, 2014)

import java.io.*;

public class SerializingObject{

public static void main(String[] args) throws IOException{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please enter File name : ");

String file = in.readLine();

System.out.print("Enter extention : ");

String ext = in.readLine();

String filename = file + "." + ext;

File f = new File(filename);

try{

ObjectOutput ObjOut = new ObjectOutputStream(new FileOutputStream(f));

ObjOut.writeObject(f);

ObjOut.close();

System.out.println(
"Serializing an Object Creation completed successfully.");

}

OODJ Individual Assignment(CT038-3-2) 2014

27


catch(IOException e){

System.out.println(e.getMessage());

}

}

}

OODJ Individual Assignment(CT038-3-2) 2014

28


4.0 Sample outputs

i. Login Page



Figure: 1

Login page is created for the staffs of the hotel. Only the authorized staffs with valid
username and password can access this system.









OODJ Individual Assignment(CT038-3-2) 2014

29



ii. Register new user


Figure: 2
This page enables admin to register new user of the system such as reservation staff, front
desk staff and cleaning staff.
OODJ Individual Assignment(CT038-3-2) 2014

30


iii. Register New Customer Profile




Figure: 3
This page is basically enable the reservation staff to update new customer information into
the hotel database system.










OODJ Individual Assignment(CT038-3-2) 2014

31


iv. Update booking



Figure: 4

This page is created to update booking information for the customer such as type of room
chosen, customer details, check in and checkout date as well.
OODJ Individual Assignment(CT038-3-2) 2014

32


v. Update Room Status

Figure: 5


Figure: 6
Figure 5 and 6 are created for the cleaning staff to update the room status after the check out
procedure has been done by the front desk staff.
OODJ Individual Assignment(CT038-3-2) 2014

33



5.0 Assumption

To make the system become better in the future, the programmer should connect the
system with database to keep and store the user record which can be permanently store in
the database. Besides that, implementation of Graphical User Interface is relevant to make
an interactive user friendly system.
In short, advancing the Object Oriented Concept into the important to make the
system execute properly and to produce more extensible system.



OODJ Individual Assignment(CT038-3-2) 2014

34



6.0 Conclusion

This assignment main purpose is to develop a hotel room management system which
will be used for the hotel staff to help the customers to do bookings, check in and check out.
Besides that, this system also helps hotel staffs to update the status of each room time to time.
This Hotel Room Management System will be very useful for the user because it helps the
staff and administrator to manage all records in the system, and helps the users to make the
reservation easier with different level of user access.

In implementation users has much flexibility to run this program because every user
has different access control to perform selected feature in the system. In conclusion object
oriented programming concept is higher usability in order to make task easy.







OODJ Individual Assignment(CT038-3-2) 2014

35


7.0 References

Codeproject.com. 2013. Introduction to Object Oriented Programming Concepts (OOP) and
More - CodeProject. [online] Available at:
http://www.codeproject.com/Articles/22769/Introduction-to-Object-Oriented-
Programming-Concep#OOP [Accessed: 16 Apr 2014].
Download.oracle.com. 2014. Lesson: Object-Oriented Programming Concepts (The Java
Tutorials > Learning the Java Language). [online] Available at:
http://download.oracle.com/javase/tutorial/java/concepts/ [Accessed: 16 Apr 2014].
Google+, C. 2014. Java Serialization,Serializing an Object in Java,Serialization in Java.
[online] Available at:
http://www.roseindia.net/java/example/java/io/SerializingObject.shtml [Accessed: 16
Apr 2014].
Home.cogeco.ca. 2014. Java Tutorial 4 - Inheritance and Polymorphism. [online] Available
at: http://home.cogeco.ca/~ve3ll/jatutor4.htm [Accessed: 16 Apr 2014].
Mactech.com. 2014. MacTech | The journal of Apple technology.. [online] Available at:
http://www.mactech.com/articles/mactech/Vol.14/14.04/JavaSerialization/index.html
[Accessed: 16 Apr 2014].
Searchsoa.techtarget.com. 2014. What is object-oriented programming (OOP)? - Definition
from WhatIs.com. [online] Available at:
http://searchsoa.techtarget.com/definition/object-oriented-programming [Accessed: 16
Apr 2014].
Tutorialspoint.com. 2014. Java - Encapsulation. [online] Available at:
http://www.tutorialspoint.com/java/java_encapsulation.htm [Accessed: 16 Apr 2014].
OODJ Individual Assignment(CT038-3-2) 2014

36



OODJ Individual Assignment(CT038-3-2) 2014

37

You might also like