Object Oriented Programming Report
Object Oriented Programming Report
Introduction 1
Use Cases That Summarize The Specification 1
UML Diagram 2
Use Case Diagram 3
The Class Diagram 4
The Sequence Diagram 5
Source Code 6
Output 11
Short Reflection 12
Conclusion 12
List of Figures
Fig I: Use Case Diagram 3
Fig II: Class Diagram 4
Fig III: Sequence Diagram 5
Introduction
Our task was to write a simple Java terminal application using polymorphism, inheritance, and
interfaces as well as a few diagrams, such as class diagrams, sequence diagrams, and use case
diagrams. Our study of the ideas contained in business plans involving customer bill payments
was greatly helped by these diagrams. In this programming, we used the idea to calculate the
total sales payment. The Alex Bob Café accepts cash purchases as well as credit card payments
made with MasterCard and Visa.
The fee, which is 1.5% for the Amex Visa Card and 3% for Mastercard, was calculated using a
system interface. Customers are free to choose from the choices that are available. Additionally,
there is a cost to get the most recent updated payment.
We mostly used an interface to refer to the type of class in the system. Class and interface are
similar. It is just a collection of dispassionate strategies. The abstract methods of an interface
are inherited by a class that uses the interface. In addition to abstract methods, an interface
may also contain constants, default methods, static methods, and nested classes.
1
UML Diagram
In order to better understand, update, maintain, or document information about the system, a
UML diagram is a diagram based on the UML (Unified Modeling Language) that aims to visually
describe a system together with its primary players, roles, actions, artifacts, or classes.
2
Use Case Diagram
Typically, the actors and use cases listed below would be included in a use case diagram for
processing a purchase:
1. Customer: The main participant in the system who adds things to their shopping cart
and places an order to start the purchasing process.
2. Shopping Cart: A use case that illustrates how customers add and remove items from
their shopping cart.
3. Order: A use case for the procedure of placing an order for the goods in the customer's
shopping cart.
4. Payment: A use case that illustrates how the order's payment is handled.
5. Shipping: A use case that depicts the process of shipping the merchandise to the
consumer.
6. Inventory: A use case for the procedure of determining an item's availability and
updating the inventory accordingly.
The consumer would be linked to the use cases for the shopping cart, order payment, shipping,
and inventory in the diagram, with arrows denoting the direction of interactions between them.
You may also have a character named "Admin" who can deal with problems like canceled orders
or adding/removing things.
A new use case for "Process Digital Currency Payment" that covers the procedures for choosing
a digital currency payment option, inputting the digital wallet address, and showing the updated
sale total may be added to the use case diagram.
3
The Class Diagram
The new class "DigitalCurrencyPayment" may be added to the class diagram as a subclass of the
already-existing "Payment" class. A relationship between the classes "Order" and
"DigitalCurrencyPayment" should be shown in the class diagram to show that a digital currency
payment may be connected to an order.
4
The Sequence Diagram
The new "Process Digital Currency Payment" use case, which depicts the interactions between
the customer, the system, and the digital currency payment gateway, may be added to the
sequence diagram.
5
Source Code
Amexcardpayment.java
6
Cardtype.java
Cashpayment.java
7
Main.java
8
MasterCardPayment.java
9
Paymentype.java
Surcharge.java
10
Output:
11
Short Reflection
When considering the value of requirements design and analysis, UML diagrams, and
object-oriented programming with interfaces and polymorphism, it's crucial to keep in mind
that by developing and analyzing the requirements in advance, the system will be created to
satisfy the user's demands. UML diagrams offer a precise visual depiction of how the system is
designed to satisfy the user's needs. Before any coding is done, UML diagrams help to spot any
possible problems by providing a clear visual representation of the system's design. The
development process is more effective when interfaces and polymorphism are used in
object-oriented programming because they provide flexibility and reuse of code.
In our instance, we discovered that once I started coding, we needed to make changes to the
initial UML diagrams since we had overlooked some needs and restrictions during the early
round of research and design.
Conclusion
Through the usage of several UML diagrams, including use case diagrams, class diagrams, and
sequence diagrams, we learnt about polymorphism, inheritance, and the interface in Java. It
also taught us how to use these payment system concepts in our daily life in a café or any other
industry with a high volume of client transactions.
12