Software Engineering: Analysis and Design of Payment System Project

Verified

Added on  2022/10/03

|17
|1766
|453
Project
AI Summary
This project showcases the design and development of a Java console application for a payment system, addressing the needs of a small business. The assignment begins with a comprehensive requirements analysis and design phase, utilizing Use Case, Class, and Sequence diagrams to visually represent the system's functionality. The core of the project involves the implementation of the payment system in Java, allowing users to input purchase amounts and select payment methods, including cash and card options with associated surcharges. Object-oriented programming principles, such as interfaces and polymorphism, are employed to achieve flexibility and extensibility. The report concludes with a reflection on the learning experience, emphasizing the practical application of software engineering concepts and techniques.
Document Page
Running head: SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
Software Engineering: Analysis and Design
Name of the Student:
Name of the University:
Author Note:
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
Table of Contents
Introduction................................................................................................................................3
Requirements Analysis and Design.......................................................................................3
Development of Code............................................................................................................3
Reflection on Learning.........................................................................................................12
Requirement Design and Analysis...................................................................................12
UML diagrams.................................................................................................................12
Object-oriented programming with interfaces and polymorphism..................................12
Conclusion................................................................................................................................14
Reference List..........................................................................................................................15
Document Page
2SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
Introduction
Bob and Alice are a small business owner, and they would like to improve their
business transaction. They want to offer various credit card payment options to allow the
customers to purchase when they have not enough cash in their hand. And they also like to
add a Bitcoin payment in the near future. In this report, we will discuss the requirements
designs and analysis to virtually representing the system. Next, the implementation of the
payment system that allows to enter total purchase amount and to select a payment method
either a cash payment or card payment will be discussed. For payment using cash, there is no
addition of surcharges. For payment using the card, the program calculates the total amount,
including surcharges. Finally, the object oriented programming concept that is used to
achieve the system are discussed.
Requirements Analysis and Design
A Use Case Diagram for Payment Processing System
Document Page
3SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
Use Case Diagram for Payment Processing System
Use Cases summarizing the requirements of the program
Objects involve in Used Case Diagram:
Use Case: this represent an action or a function inside the system.
Actor: this represents an entity in the system who perform an action.
Package: this represents an optional element in the complex diagram. To group multiple uses cases
packages can be used.
System: this describes the scope of a use case system and represented by a rectangle. This is
optional but it can be used to visualizing a large system.
A Class Diagram of the intended system
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
4SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
Class diagram showing payment using different method
A Sequence Diagram for processing a customer’s purchase
A Sequence Diagram for Payment Processing (either by cash or by card)
Development of Code
package paymentdetails;
import static java.lang.System.exit;
<<Interface>>
Payment
surcharge
amexcard
payment_calc()
CashSales
surcharge
amexcard
payment_calc()
MasterCardSales
surcharge
amexcard
payment_calc()
TotalProductSales
surcharge
amexcard
payment_calc()
AmexCardSales
surcharge
amexcard
payment_calc()
VisaCardSales
surcharge
amexcard
payment_calc()
Document Page
5SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
import java.util.Scanner;
// A simple payment interface
interface Payment {
// constant fields declaration
final float surcharge = 0.015f;
final float amexcard = 0.03f;
// declare an abstract and public method payment_calc
void payment_calc( float x);
}
// Class CashSales implements Payment interface
class CashSales implements Payment{
@Override
// Redefine the abstract method in CashSales Class
public void payment_calc(float x) {
System.out.println(x);
}
}
Document Page
6SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
// Class MasterCardSales implements Payment interface
class MasterCardSales implements Payment {
@Override
// Redefine the abstract method in MasterCardSales Class
public void payment_calc(float x){
double calc_Sc = x * surcharge ;
double total = x + calc_Sc ;
System.out.println("\nTotal Payable Amount : " + total);
}
}
// Class VisaCardSales implements Payment interface
class VisaCardSales implements Payment {
@Override
// Redefine the abstract method in VisaCardSales Class
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
7SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
public void payment_calc(float x){
double calc_Sc = x * surcharge ;
double total = x + calc_Sc ;
System.out.println("\nTotal Payable Amount : " + total);
}
}
// Class AmexCardSales implements Payment interface
class AmexCardSales implements Payment {
@Override
// Redefine the abstract method in AmexCardSales Class
public void payment_calc(float x){
double calc_Sc = x * amexcard ;
double total = x + calc_Sc ;
System.out.println("\nTotal Amount Payale : " + total);
Document Page
8SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
}
}
// Class TotalProductSales implements Payment interface
class TotalProductSales implements Payment {
@Override
// Redefine the abstract method in TotalProductSales Class
public void payment_calc(float x){
System.out.println("\nTotal Product Sales : " + x);
}
}
public class PaymentDetails {
public static void main(String[] args) {
// TODO code application logic here
// creating an inatance of Bicycle
Document Page
9SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
// doing some operations
Scanner sc = new Scanner(System.in); // Scanner Class object creation
CashSales cs = new CashSales(); //Creating an object of CashSales Class
MasterCardSales mc = new MasterCardSales(); //Creating an object of MasterCardSales
Class
VisaCardSales vc = new VisaCardSales(); ////Creating an object of VisaCardSales Class
AmexCardSales ac = new AmexCardSales(); //Creating an object of AmexCardSales
Class
TotalProductSales ps = new TotalProductSales(); //Creating an object of
TotalProductSales Class
int select; // An integer to select an option
float amount , amount1, amount2 , amount3, t1 = 0, t2 = 0, t3 = 0, t5; // local variables
do { // Starting do-while loop
//display menu list to user
//ask user to select one payment option and make sure the option is valid option between
1 to 6
System.out.println("Select your payment option : ");
System.out.println("1) Cash Sales ");
System.out.println("2) AmexCard Sales ");
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
10SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
System.out.println("3) MasterCard Sales ");
System.out.println("4) VisaCard Sales ");
System.out.println("5) Total Product Sales ");
System.out.println("6) Quit ");
System.out.println();
System.out.print(" Enter your choice (1-6): ");
select = sc.nextInt();
switch (select) {
case 1: System.out.println("\nEnter the total amount for Sale : " );
amount = sc.nextFloat();
System.out.println("\nTotal Cash Amount : " );
cs.payment_calc(amount); // Calling an abstact method of CashSales Class
throgh class instance variable
t1 = amount;
break;
case 2: System.out.println(" \n Enter the total amount for Sale : " );
amount1 = sc.nextFloat();
// Perform Calculation
t2 = amount1;
Document Page
11SOFTWARE ENGINEERING: ANALYSIS AND DESIGN
t2 += (amount1*3)/100;
ac.payment_calc(amount1); // Calling an abstact method of MasterCardSales
Class throgh class instance variable
break;
case 3: System.out.println("\nEnter the total amount for Sale : " );
amount3 = sc.nextFloat();
// Perform Calculation
t5 = amount3;
vc.payment_calc(amount3); // Calling an abstact method of VisaCardSales Class
throgh class instance variable
break;
case 4: System.out.println("\nEnter the total amount for Sale : " );
amount2 = sc.nextFloat();
t3 = amount2 ;
mc.payment_calc(amount2); // Calling an abstact method of AmexCardSales
Class throgh class instance variable
System.out.println();
break;
case 5: float t4 = t2 + t1 ;
chevron_up_icon
1 out of 17
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]