Professional Documents
Culture Documents
CT038-3-2-OODJ
1.2 Assumptions
Page | 1
2. Requirement Analysis
2.1 Use Case Diagram
Page | 2
system.
2. The staff selects the type of staff he/she belongs to, and enter
staff ID and password.
3. The system searches in the corresponding text file storing staff
ID and password to verify the inputs, and allows the user to
login to the system. (refer Alternative Flows)
3. The staff ID or password is incorrect, so the system displays a
Alternative Flows
message indicating incorrect staff ID or password.
Page | 3
1. This use case begins when the admin activates the option to
manage managing staff accounts.
2. a. The admin enters information of a new managing staff and
clicks “Add” button. (refer Alternative Flows)
b. The admin selects a managing staff from the table, updates
information in the fields and clicks “Edit” button. (refer
Alternative Flows)
Main Flows c. The admin selects a managing staff from the table and clicks
“Delete” button.
3. a. The system saves the information of managing staff into the
text file.
b. The system updates the managing staff information and saves
it into the text file.
c. The system removes the information of selected managing
staff from the text file.
2. a. (i) The information entered is not following the specified
format (staff ID must be numeric, password must be 8 to 16
characters, name must consist of alphabets only, and phone
number must be 10 digits), so the system displays a message
specifying the required format.
Alternative Flows b. (i) The information entered is not following the specified
format (password must be 8 to 16 characters, name must consist
of alphabets only, and phone number must be 10 digits), so the
system displays a message specifying the required format.
b. (ii) The staff ID is changed, so the system displays a message
informing staff ID cannot be modified.
Page | 4
f. Information of selected delivery staff is removed from the text
file storing delivery staff information.
4. This use case begins when the managing staff activates the
option to manage delivery staff accounts.
5. a. The managing staff enters information of a new delivery staff
and clicks “Add” button. (refer Alternative Flows)
b. The managing staff selects a delivery staff from the table,
updates information in the fields and clicks “Edit” button. (refer
Alternative Flows)
Main Flows c. The managing staff selects a delivery staff from the table and
clicks “Delete” button.
6. a. The system saves the information of delivery staff into the
text file.
b. The system updates the delivery staff information and saves it
into the text file.
c. The system removes the information of selected delivery staff
from the text file.
3. a. (i) The information entered is not following the specified
format (staff ID must be numeric, password must be 8 to 16
characters, name must consist of alphabets only, and phone
number must be 10 digits), so the system displays a message
specifying the required format.
b. (i) The information entered is not following the specified
format (password must be 8 to 16 characters, name must consist
Alternative Flows
of alphabets only, and phone number must be 10 digits), so the
system displays a message specifying the required format.
b. (ii) The staff ID is changed, so the system displays a message
informing staff ID cannot be modified.
b. (iii) Managing staff who are not admin attempts to change the
name of delivery staff, so the system displays a message
informing only admin can modify name for delivery staff.
Page | 5
system.
The text file storing order details is updated with latest and correct
Postconditions
data.
1. This use case begins when a managing staff activates the option
to manage order.
2. The staff updates information in the fields and clicks “Edit”
Main Flows
button. (refer Alternative Flows)
3. The system updates the staff information and saves it into the
corresponding text file.
3. (i) The information entered is not following the specified format
(password must be 8 to 16 characters, and phone number must
be 10 digits), so the system displays a message specifying the
Alternative Flows
required format.
(ii) The staff attempts to change staff ID or name, so the system
displays a message informing staff ID or name is not editable.
Page | 6
2.2 Class Diagram
Page | 7
3. Object Oriented Programming Concepts
Page | 8
3.1 Object and Class
3.1.1 Object
Objects are building blocks of object oriented programming that represent real life entities
(Cabral, 2019). An object has state, behavior, and identity. State of an object is defined by
fields, constants, and properties, while behavior of an object is defined by methods that work
as functions. Identity of an object is unique to differentiate it from other objects even if its
state is identical to another object.
3.1.2 Class
Classes are collections of similar objects. A class is a blueprint or template of an object that
describes the state and behavior of the object, while an object is an instance of a class that has
unique values to properties defined in the class (Doherty, 2020).
Page | 9
Figure 3.1.3.2 ManagingStaff Class
Page | 10
Pictures above show the classes created in the courier service system. “ManagingStaff”,
“DeliveryStaff”, and “Order” classes are created to provide blueprints of managing staff,
delivery staff, and order objects respectively, while “Staff” class is created to achieve
abstraction in object oriented programming which can enable code reusability. The
constructors are used to create objects of the classes. The parameterized constructor that takes
in “id” and “password” arguments is used to create an object of “ManagingStaff” class or
“DeliveryStaff” class for logging in the courier service system. Meanwhile, an object of
“ManagingStaff” class or “DeliveryStaff” class will be created using the other parameterized
constructor that takes in five arguments when adding a new staff or updating staff
information.
“Status” and “Feedback” are enumerations, as known as enums, which are special “classes”
that represent groups of unchangeable variables that are public, static, and final by default
(Shah, 2020). This is because there is only a small set of possible values for delivery status
and feedback of orders unlike other variables of order objects. Keyword “enum” is used to
declare an enumeration in Java.
Page | 11
Figure 3.1.3.7 Codes of Add Button
Picture above shows an object of “Order” class named “newOrder” created when managing
staff click “Add” button to add a new order. The object is first created with the blank
constructor, then variables are set using the mutators. Note that an object can access the data
members and methods of its class using dot (‘.’) operator.
Page | 12
Figure 3.1.3.8 Codes of Update Button
Picture above shows an object of “Order” class named “editOrder” created when managing
staff click “Update” button to update details of an order. The object is created with the
parameterized constructor to assign specific values to instance variables of the order.
3.2 Inheritance
Inheritance is a mechanism in which one class derives properties and functionalities of
another class, also known as extending class as the keyword for deriving a class in Java is
“extends” (Vaidya, 2020). The class being inherited is called superclass, parent class, or base
class, while the inherited class is called subclass, child class, or derived. A superclass is a
generalization of one or more subclasses while a subclass is a specialization of a superclass
(Jenkov, 2015). Inheritance represents is-a relationship, as known as parent-child relationship,
between two classes. For example, a car is a vehicle, thus class “car” extends class “vehicle”,
where vehicle is more generalized and car is more specialized.
There are five types of inheritances in object oriented programming (Singh, 2020):
Page | 13
Multilevel inheritance: A class extends a derived class.
Hierarchical inheritance: More than one class extends a single class.
Multiple inheritance: A class inherits state and behavior from more than one class.
Hybrid inheritance: A combination of more than one type of inheritance.
Java does not support multiple inheritance, and thus does not support hybrid inheritance, but
these types of inheritance can be achieved by interfaces. In other words, a class can extend
merely one class in Java.
As discussed previously, “extends” is the keyword to derive a class in Java. Pictures above
show the declaration of the subclasses. The extending classes are subclasses while the
extended class is superclass. Staff is more generalized while managing staff and delivery staff
are specialization of staff.
Page | 14
Figure 3.2.1.3 Staff Class
Picture above shows the superclass “Staff”. Since “ManagingStaff” and “DeliveryStaff”
classes inherit “Staff”, all public and protected fields, as well as methods defined in the
superclass are all derived. Note that if private variable(s) is declared in the “Staff” class, both
“ManagingStaff” and “DeliveryStaff” classes will not inherit the variable(s).
Page | 15
Figure 3.2.1.4 DeliveryStaff Class
With inheritance, declaration of fields in the subclasses is not needed, and the properties,
methods, and constructors of superclass can be accessed using the keyword “super”. Picture
above shows the “DeliveryStaff” class. As shown in the picture, “super” keyword is used to
invoke constructors of “Staff” class. This also applies for the “ManagingStaff” class.
To sum up, the objects created in the subclasses will have “id”, “password”, “name”,
“phone”, and “email”, and can invoke “loginSystem”, “manageIndividual”, and
“updateOrder” methods as well as accessors, mutators, and constructors without repeating the
codes in the subclasses. This shortens the length of codes, and enhances the reusability and
maintainability of codes.
Page | 16
Figure 3.2.1.5 ManagingStaff Class
Other than that, a subclass may have methods that are not in its superclass. Picture above
shows the “ManagingStaff” class, which has extra methods declared. These methods can be
called by objects of “ManagingStaff” class only.
3.3 Polymorphism
Polymorphism is one of the four object oriented concepts in Java, it occurs when more than
one classes are related with each other through the implementation of inheritance (Guru99,
2020). Inheritance allows the subclasses to inherit attributes and methods of the superclass
Page | 17
while polymorphism allows the modification of methods based on programmer requirements.
To simply put, it enables performing a single behavior in numerous ways.
There are two main types of polymorphism which are static and dynamic (Janssen, 2017).
Page | 18
Dynamic polymorphism refers to implementing overriding methods. In overriding methods,
the methods are being modified (Tyagi and Miglani, 2020). Subclasses can modify some part
of a method or the entire method based on requirements of the subclasses.
Page | 19
“Staff”, “ManagingStaff”, and “DeliveryStaff” classes have two constructors each. Although
“Staff” class is an abstract class, it has constructors for initializing fields of an object.
Constructor chaining mechanism is used in both “ManagingStaff” and “DeliveryStaff”
classes, which the constructors call other constructors from the “Staff” superclass (Palkar,
2020).
3.4 Abstraction
Abstraction is a process of hiding unnecessary details and showing only essential information
to users in order to handle complexity (Janssen, 2017). In object oriented programming
language, abstraction is the process of hiding implementation codes and exposing system
functionality to users, enabling users to focus on what the object does instead of how it does
(Filip, 2017). For instance, managing staff keys in details of an order and clicks “add” button
to add the order, but the operations of the system such as what happens when the “add”
button is clicked and how order details are stored into file are abstracted from the managing
staff.
Approaches to achieve abstraction in Java are abstract classes and interfaces. An abstract
class is a superclass that defines implementations and behaviors to be shared across a set of
classes (Kay, 2019). It is a restricted class that can never be instantiated. It may or may not
have abstract methods, and can have concrete methods. An abstract method is a method with
no implementation, which is to be overridden by inherited subclasses of the abstract class.
An interface is a blueprint for implementing a class that has no constructor but public and
abstract methods, enabling total abstraction and loose coupling in Java (MV, 2020). Also,
variables defined in an interface are public, static, and final by default. A class can extend
Page | 20
only one class but can implement multiple interfaces, so interfaces are often used to achieve
multiple inheritance in Java (Kumar and Nitsdheerendra, 2020).
Although both approaches are similar, an abstract class enables grouping of related classes
while an interface can be implemented by unrelated classes (Deep, 2019). By implementing
the abstraction concept in object oriented programming, overall complexity of design and
implementation of a program can be reduced (Miglani, 2019).
To declare an abstract class, “abstract” keyword must be used. Picture above shows the
declaration of the “Staff” abstract class.
Page | 21
Figure 3.4.1.2 Staff Abstract Class
Picture above shows the abstract class “Staff” with five protected fields, accessors, mutators,
and three concrete methods.
Page | 22
Figure 3.4.1.3 Codes of Login Button
Consider the “loginSystem” method defined in “Staff” class, although return type and
parameter type are both “Staff” class, the “staff” object passed in as an argument and returned
must be an object of either “ManagingStaff” class or “DeliveryStaff” class because “Staff”
abstract class cannot be instantiated. As shown in picture above, when “Login” button is
clicked, an object of either “ManagingStaff” class or “DeliveryStaff” class will be created
and invoke the “loginSystem” method from the “Staff” abstract class, also declare the
returned “Staff” class object as an object of “ManagingStaff” class or “DeliveryStaff” class.
Page | 23
Figure 3.4.1.4 GUI of Individual Profile Management
Page | 24
Picture above shows the codes of the “Edit” button. The system will first verify input of
information, then update and save staff information in appropriate text files. However, these
system operations are all abstracted from the users.
With abstraction, codes can be simplified, and staff can focus on the functionality of the
courier service system instead of the way it performs actions to accomplish tasks and provide
function.
3.5 Encapsulation
Page | 25
4. Conclusion
In conclusion, the courier service system that was design had implemented all the object-
oriented concepts allowing a more productive and effective way of delivering parcel and
managing data stored.
Throughout the process of building and designing the system, implementing all 4
fundamentals object-oriented concepts which are abstraction, encapsulation, inheritance ,and
polymorphism were our top priority. Implementing these concepts, bring tremendous amount
of benefits especially in the programming part. It helps in code flexibility as code are reusable
in many ways. Aside from only benefitting the programmers, these object-oriented concepts
also help the end-users which are the managing and delivery staff as the program is simple
and easily understandable.
Page | 26
5. Appendix: Graphic User Interface (GUI)
5.1 Login
Page | 27
5.2 Manage Managing Staff Account
Manage Managing Staff Account is only allowed for the admin (staff ID is 100)
Page | 28
Create a new managing staff account
5.3 Manage
Delivery Staff
Account
Create a new
delivery staff
account. Similar to
the previous figure ..
, updating is
possible too.
5.4 Manage
Individual Profile
Both staff either managing staff or delivery
staff can edit his or her own personal details
(password, phone number and email address
only)
Page | 29
5.5 Manage Order
Page | 30
Page | 31
5.7 View Report
Page | 32
6. References
Agarwal, H. (2020) Encapsulation in Java [Online]. Available from:
https://www.geeksforgeeks.org/encapsulation-in-java/ [Accessed: 24th November 2020]
Cabral, E. E. (2019) OOPS Concepts And .NET - Part One - Classes, Objects, And Structures
[Online]. Available at: https://www.c-sharpcorner.com/article/oops-concepts-and-net-part-1-
classes-objects-and-structu/ [Accessed: 23rd November 2020]
Cardin, R. (2018) The Secret Life of Objects: Information Hiding [Online]. Available from:
https://dzone.com/articles/the-secret-life-of-objects-information-hiding [Accessed: 23rd
November 2020]
Deep, A. (2019) When to Use Abstract Class and Interface [Online]. Available at:
https://dzone.com/articles/when-to-use-abstract-class-and-intreface [Accessed: 23rd
November 2020]
Guru99 (2020) Encapsulation in Java OOPs with Example [Online]. Available from:
https://www.guru99.com/java-oops-encapsulation.html [Accessed: 23rd November 2020]
Guru99 (2020) Polymorphism in Java OOPs with Example [Online]. Available from:
https://www.guru99.com/java-inheritance-polymorphism.html [Accessed: 23rd November
2020]
Janssen, T. (2017) OOP Concept for Beginners: What is Abstraction? [Online]. Available at:
https://stackify.com/oop-concept-abstraction/ [Accessed: 23rd November 2020]
Janssen, T. (2017) OOP Concept for Beginners: What is Encapsulation [Online]. Available
from: https://stackify.com/oop-concept-for-beginners-what-is-encapsulation/ [Accessed: 23rd
November 2020]
Page | 33
Janssen, T. (2017) OOP Concept for Beginners: What is Inheritance? [Online]. Available at:
https://stackify.com/oop-concept-inheritance/ [Accessed: 23rd November 2020]
Janssen, T. (2017) OOP Concept for Beginners: What is Polymorphism [Online]. Available
from: https://stackify.com/oop-concept-polymorphism/ [Accessed: 24th November 2020]
Kasyap, K. (2020) What is the purpose of a constructor in Java? [Online]. Available from:
https://www.tutorialspoint.com/what-is-the-purpose-of-a-constructor-in-java [Accessed: 24th
November 2020]
Leahy, P. (2020) Using Accessors and Mutators in Java [Online]. Available from:
https://www.thoughtco.com/accessors-and-mutators-2034335 [Accessed: 23rd November
2020]
Minh, N. H. (2019) What is Inheritance in Java - The WHAT, WHY and HOW [Online].
Available at: https://www.codejava.net/java-core/the-java-language/what-is-inheritance-in-
java-the-what-why-and-how [Accessed: 23rd November 2020]
Page | 34
Nick (2020) Polymorphism, Encapsulation, Data Abstraction and Inheritance in Object-
Oriented Programming [Online]. Available at: https://www.nerd.vision/post/polymorphism-
encapsulation-data-abstraction-and-inheritance-in-object-oriented-programming [Accessed:
23rd November 2020]
Palkar, R. (2020) Why Does An Abstract Class Needs A Constructor? [Online]. Available at:
https://www.c-sharpcorner.com/article/why-does-abstract-class-needs-a-constructor/
[Accessed: 24th November 2020]
Shah, A. (2020) Beginner’s Guide to Java eNum – Why and for What should I use Enum?
Java Enum Examples [Online]. Available at: https://crunchify.com/why-and-for-what-should-
i-use-enum-java-enum-examples/ [Accessed: 24th November 2020]
Vaidya, N. (2020) Inheritance in Java – Mastering OOP Concepts [Online]. Available at:
https://www.edureka.co/blog/inheritance-in-java/ [Accessed: 23rd November 2020]
Page | 35