oodj jeya documentation(1)

Upload: tulasi-nathan

Post on 11-Oct-2015

75 views

Category:

Documents


0 download

TRANSCRIPT

Table of Contents

1.0Introduction22.0UML Diagrams3i.Use Case Diagram3ii.Use case specifications4iii.Activity diagram11iv.Class Diagram163.0Object Oriented Programming18i.What is object oriented programming?18ii.Object oriented concepts20(i)Abstract classes20(ii)Polymorphism21(iii)Encapsulation23(iv)Serialization254.0Sample outputs28i.Login Page28ii.Register new user29iii.Register New Customer Profile30iv.Update booking31v.Update Room Status325.0Assumption336.0Conclusion347.0References35

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.

2.0 UML Diagramsi. Use Case Diagram

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

LoginUse Case Name : Login

Scenario :Staffs login into the system

Triggering Event : When staffs select login option

BriefDescription :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.

Use Case Name : Register user

Scenario :Register new user into the system

Triggering Event : When User select register customer option

BriefDescription :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

Register User

Update customer detailsUse Case Name : Update customer details

Scenario :Update customer details from the system

Triggering Event : When User select update customer details option

BriefDescription :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 details1. 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

Use Case Name : Update Booking

Scenario :Update booking information for customers

Triggering Event : When User select update booking option

BriefDescription :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 booking4.1 Update booking status of the customer4.2 Manage check in and check out of the customer4.3 Save changes

Update Booking

Check InUse Case Name : Check in

Scenario :Staff manage check in for the customer into the system

Triggering Event : When staff select check in option

BriefDescription :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 customer5.2 Check in successful

Check OutUse Case Name : Check out

Scenario :Staff check out for customer from the system

Triggering Event : When staff select check out option

BriefDescription :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 customer6.2 Check out is successful

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

BriefDescription :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 status7.2 Save the changes into the database.

iii. Activity diagram User Login Activity Diagram

Administrator Activity Diagram

Reservation Staff Activity Diagram

Front Desk Staff Activity Diagram

Cleaning Staff Activity Diagram

iv. Class Diagram

Figure: 1

Class diagram

Figure: 23.0 Object Oriented Programming

i. What is object oriented programming?Object oriented programming (OOP) represents a programming language model ordered around objectsrather 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 producesoutput dataIn 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 littlewidgetson 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)

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.

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 shapecolor = newColor; / / change value of instance variableredraw(); / / 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

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:

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 variableredraw(); / / 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.

(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; }

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; }}

(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() 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() 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.

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

importjava.io.*;

publicclassSerializingObject{publicstaticvoidmain(String[]args)throwsIOException{BufferedReaderin=newBufferedReader(newInputStreamReader(System.in));System.out.print("PleaseenterFilename:");Stringfile=in.readLine();System.out.print("Enterextention:");Stringext=in.readLine();Stringfilename=file+"."+ext;Filef=newFile(filename);try{ObjectOutputObjOut=newObjectOutputStream(newFileOutputStream(f));ObjOut.writeObject(f);ObjOut.close();System.out.println("SerializinganObjectCreationcompletedsuccessfully.");}catch(IOExceptione){System.out.println(e.getMessage());

}}

} 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.

ii. Register new user

Figure: 2This page enables admin to register new user of the system such as reservation staff, front desk staff and cleaning staff.iii. Register New Customer Profile

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

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.v. Update Room Status

Figure: 5

Figure: 6Figure 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.

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 thedatabase. Besides that, implementation of Graphical User Interface is relevant to make aninteractive 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.

6.0 Conclusion

This assignment main purpose is todevelop 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. ThisHotel 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 withdifferent level of useraccess.

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.

7.0 References

Codeproject.com. 2013.Introduction toObject Oriented ProgrammingConcepts (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 ProgrammingConcepts (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 Tutorial4 - 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].