Assignment OOP
Assignment OOP
“City Bookshop” is one of the new bookshop located in the heart of the city. The company
planned to implement an application in order to automate transaction process
Manager: (can perform all the functionality as cashier plus the following)
1. Create a new account (can have different account types)
You are required to apply OOP concepts for the above scenario. Data need to be saved and
retrieved from a File
Part A: Report
Task 1.Provide design solution (UML diagrams) for the above mention Scenario. Provide
clear explanation for all the diagrams mention below. (Provide assumption if necessary) (30
marks) (LO2)
a) Use case Diagram
b) Class Diagram
c) Sequence Diagram
Task 2: Develop suitable system for the above scenario based on the design. Required to use
Object Oriented concepts (Object, Class, Abstraction, Inheritance, Encapsulation and
Polymorphism) for the development. Document the main functionalities and Object Oriented
concepts applied with proper explanation and source code. (Marks 20) (LO1, LO3)
Task 3: Provide a user manual for the developed solution (Marks 10) (LO3)
Part B: Demonstration
Task 4: System demonstration. System should work according to the expected
functionalities. Should be able to demonstrate Object Oriented concepts (Object, Class,
Abstraction, Inheritance, Encapsulation, and Polymorphism) applied to the given scenario.
Acknowledgement
I would like to thank my deepest appreciation to all those who encouraged me the possibility
to complete this assignment. A special thank for our lecturer Mrs. Upeka whose contribution
in stimulating suggestions and encouragement, helped me to coordinate this assignment.
In this module I learned Object Oriented Programing properly and clearly. It’s very helps for
me to continue the next level of study. Again, I would like to thank everyone who has
supported me through entire process.
Introduction
“City Bookshop” is one of the new bookshop located in the city. The company planned to
implement an application in order to automate transaction process there are several functions
in this JAVA application such as login, manage books, manage categories, etc. there are two
authentication levels such as managers and cashiers. Managers has their own functions and
cashiers have their own functions such as search books/categories and view books.
In this assignment, UML Diagram, ER diagram and Sequence Diagram have been designed
with proper explanations. Then proper attractive user interfaces have been designed to get the
necessary user inputs. Then an interactive JAVA application has been developed and added it
to proper validation mechanisms in order to restrict invalid entries to the system. Finally,
proper conclusion have been included.
Task A
Provide design solution (UML diagrams) for the above mention Scenario. Provide clear
explanation for all the diagrams mention below.
When it comes to relationship and cardinality ratio of this use case diagram, Login and both
actors have many-to-many relationship because many managers and cashiers can login many
times, Manage books, categories and users have many-to-many relationship because users
can enter many books details can enter and update many books details, search functions and
cashiers have many-to-many relationship because many cashiers can search and view many
books and the book categories.
It is easy to understand this City Bookshop JAVA application procedure by seeing above use
case diagram.
Class Diagram
According to above class diagram, it has several classes such as login, cashier options,
manager options, add books, update and delete books, add, update and delete categories. All
the classes have their own attributes and behaviors
Sequence Diagram
Interactions between classes are depicted in sequence diagrams as a series of messages sent
over time. Event diagrams is another name for them. A sequence diagram is a useful tool for
visualizing and testing different runtime situations of user and the database. These can aid in
predicting how a system will behave and identifying tasks that a class may be required to
fulfil throughout the modelling phase.
Task B
Discuss use of OOP concepts in the implementation. Provide examples with detailed
justification
OOP
Object Orientation has taken the software world by storm.As a way of creating programs it
has number of advantages. It promotes the component- based approach to software
development.
• First create a system by creating a set of objects.
• Then, you can expand the system by adding capabilities to components you have already
built or by adding new components.
• Finally, you can reuse the objects you created for the system when you built a new
system. This will substantially reduce the system development time.
What is an Object?
• A ‘thing’ may have a physical presence such as a ‘table’, ‘chair’ or an abstract concept
such as ‘a job’.
• An object is an abstract representation of a ‘thing’ in the real world.
• We simulate a problem domain in the real- world through objects.
• An object has a unique identity, attributes (What it knows or data about it), and behavior
(What it can do).
An Student object (say customer1) will have the following attributes (what it knows): name,,
address
It will have the following behavior (what it can do): set address, get address, set name
What is a Class?
• Objects are the representation of things in the real world
• Classes are templates for objects, i.e. they contain all the common properties and
behavior of a group of objects.
• All objects with the same characteristics and behaviors belongs to the same class.
Let us now look deep into what are objects. If we consider the real-worldI can find many
objects my Library management application like Member, Books, Library, etc. All these
objects have a state and behavior.
If I consider a dog, then its state is - name, breed, color, and the behavior is - barking,
wagging, running
If we are comparing with the software object with a real world object, they have very similar
characteristics.
Software objects also have a state and behavior. A software object's state is stored in fields
and behavior is shown via methods.
So in application development, methods operate on the internal state of an object and the
object-to-object communication is done via methods.
Abstraction: The ability to represent data at a very conceptual level without any details
Encapsulation: Encapsulation is placing the data and the functions that work on that data in
the same place. While working with procedural languages, it is not always clear which
functions work on which variables but object-oriented programming provides you framework
to place the data and the relevant functions together in the same object.
This is a very important concept of object-oriented programming since this feature helps to
reduce the code size.
Polymorphism: The ability to use an operator or function in different ways in other words
giving different meaning or functions to the operators or functions is called polymorphism.
Poly refers too many. That is a single function or an operator functioning in many ways
different upon the usage is called polymorphism.
User Interfaces
Main Menu -
Manager Login -
Cashier Login-
Cashier
a) View all the book details
From this function new manager accounts can be add by the manager
b) Create new user account for cashier
Inheritance
The inheritance can be defined as the process where one class acquires the properties
(methods and fields) of another. With the use of inheritance the information is made
manageable in a hierarchical order.
The class which inherits the properties of other is known as subclass (derived class, child
class) and the class whose properties are inherited is known as superclass (base class, parent
class). A class that inherits from another is called a derived class or a child class.
Polymorphism
The Polymorphism is the ability of an object to take on many forms. The most common use
of polymorphism in OOP occurs when a parent class reference is used to refer to a child class
object.
Constructors used in application
The constructor in java is a special type of method that is used to initialize the object. The
Java constructor is invoked at the time of object creation. It constructs the values i.e. provides
data for the object that is why it is known as constructor as well
Java Inheritance defines is a relationship between a super class and its subclasses. This means
that an object of a subclass can be used wherever an object of the super class can be used.
Class Inheritance in java mechanism is used to build new classes from existing classes.
Encapsulation
The Java Encapsulation in Java is a mechanism of wrapping the data (variables) and code
acting on the data (methods) together as single unit. In encapsulation the variables of a class
will be hidden from other classes, and can be accessed only through the methods of their
current class, therefore it is also known as data hiding.
User Manual
Main Menu – first main page we have to choose the user level to proceed
Manager Login – then if you are a manager you have to enter the login credentials from the
database to proceed
Cashier Login- then if you are a cashier you have to enter the login credentials from the
database to proceed
Cashier Book Manage – in cashiers menu there are book manage page we can view, insert, update,
delete and search book from that page
Cashier category Manage - in cashiers menu there are category manage page we can view, insert,
update, delete and search categories from that page
Manager cashier Manage - in managers menu there are cashier manage page we can view, insert,
update, delete and search cashiers from that page
Manager Manager Manage - in managers menu there are manager manage page we can view,
insert, update, delete and search managers from that page
Manager book Manage - in managers menu there are books manage page we can view, insert,
update, delete books from that page
Manager category Manage - in managers menu there are category manage page we can view,
insert, update, delete category from that page
Conclusion
The created bookshop system is just a modest attempt to meet the demands of a city
bookstore. A variety of user-friendly code has also been implemented.
This created application must be demonstrated to be a strong bundle capable of meeting all of
the business structure. The goal of software planning is to create a framework that allows a
manager to generate realistic predictions within a certain time period at the start of a software
project and to be updated on a frequent basis as the project proceeds.
I'd want to provide a detailed explanation of the created project scope, requirements, and
constraints. Overall, this will flexibly provide a powerful and precise overview of the
intended desktop-based explanation, as well as innovation.
When a user sends a searching request to the developed application with its related
connecting multiple database application, the application that would like to search with the
information from those MySQL databases in which search data is saved and return the result
from all the given databases, and I have also used Net Beans IDE to design my application
GUI.