Question: Unit Testing in java for the below code please can you help with Unit Testing for this code BeenzAccount.java: package beenz; import java.util.ArrayList; public class

Unit Testing in java for the below code

please can you help with Unit Testing for this code

BeenzAccount.java:

package beenz;

import java.util.ArrayList;

public class BeenzAccount extends BeenzProgram { public int accountID; public int currentBeenz; public ArrayList transactions; public BeenzAccount(int programID, String name, ArrayList prizes) { super(programID, name, prizes); transactions = new ArrayList<>(); } public void setPoints(int points) { this.currentBeenz = points; } public void burn(int burn) { if (this.currentBeenz > 0 && this.currentBeenz > burn) this.currentBeenz -= burn; else System.out.println("You do not have enough beenz to burn! Current beenz: " + this.currentBeenz); } // constraint: beenz >= prize cost public int getAccountID() { return accountID; }

public void setAccountID(int accountID) { this.accountID = accountID; }

public int getCurrentBeenz() { return currentBeenz; }

public void setCurrentBeenz(int currentBeenz) { this.currentBeenz = currentBeenz; } public boolean isEmpty() { if (this.currentBeenz == 0) { return true; } else { return false; } } public void listAvailablePrizes() { for (int i = 0; i < prizes.size(); i++) { System.out.println(prizes.get(i).getDescription()); } } public int getEmployeeID(Employee employee) { return employee.getEmployeeID(); } public void addTransaction(Transaction transaction) { this.transactions.add(transaction); } }

Transaction.java :

package beenz;

import java.util.Date;

public class Transaction { public int points; public Date date; public int transactionID; public BeenzProgram program; public Transaction(int points, Date date, int transactionID, BeenzProgram program) { super(); this.points = points; this.date = date; this.transactionID = transactionID; this.program = program; }

public int getPoints() { return points; }

public void setPoints(int points) { this.points = points; }

public Date getDate() { return date; }

public void setDate(Date date) { this.date = date; }

public int getTransactionID() { return transactionID; }

public void setTransactionID(int transactionID) { this.transactionID = transactionID; } public BeenzProgram program() { return this.program; } }

Prize.java :

package beenz;

public class Prize { public int pointsEarned; public int pointsBurned; public String description; public int prizeID; public Transaction transaction; public Prize(int pointsEarned, int pointsBurned, String description, int prizeID, Transaction transaction) { super(); this.pointsEarned = pointsEarned; this.pointsBurned = pointsBurned; this.description = description; this.prizeID = prizeID; this.transaction = transaction; }

public int getPointsEarned() { return pointsEarned; } public void setPointsEarned(int pointsEarned) { this.pointsEarned = pointsEarned; } public int getPointsBurned() { return pointsBurned; } public void setPointsBurned(int pointsBurned) { this.pointsBurned = pointsBurned; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public int getPrizeID() { return prizeID; } public void setPrizeID(int prizeID) { this.prizeID = prizeID; } public int getTransactionID() { return this.transaction.getTransactionID(); } }

Employee.java :

package beenz;

public class Employee { public int employeeID; public String name; public String title; public int phone; public String address; public String dateOfBirth; public BeenzAccount account; public Employee(String name, String title, int phone, String address, String dateOfBirth) { super(); this.name = name; this.title = title; this.phone = phone; this.address = address; this.dateOfBirth = dateOfBirth; } public void addAccount(BeenzAccount account) { this.account = account; }

public String getName() { return name; }

public void setName(String name) { this.name = name; }

public String getTitle() { return title; }

public void setTitle(String title) { this.title = title; }

public int getPhone() { return phone; }

public void setPhone(int phone) { this.phone = phone; }

public String getAddress() { return address; }

public void setAddress(String address) { this.address = address; }

public String getDateOfBirth() { return dateOfBirth; }

public void setDateOfBirth(String dateOfBirth) { this.dateOfBirth = dateOfBirth; }

public BeenzAccount getAccount() { return account; }

public void setAccount(BeenzAccount account) { this.account = account; } public int getEmployeeID() { return employeeID; }

public void setEmployeeID(int employeeID) { this.employeeID = employeeID; } }

BeenzProgram.java :

package beenz; import java.util.ArrayList;

public class BeenzProgram { public int programID; public String name; public ArrayList employees; public ArrayList accounts; public ArrayList prizes; public BeenzProgram(int programID, String name, ArrayList prizes) { super(); this.programID = programID; this.name = name; this.employees = new ArrayList<>(); this.accounts = new ArrayList<>(); this.prizes = prizes; }

public void enroll(Employee employee) { for (int i = 0; i < employees.size(); i++) { if (employee.getEmployeeID() == this.employees.get(i).getEmployeeID()) { System.out.println("Sorry this employee is already enrolled in the program"); return; } // constraint: if employee is enrolled } this.employees.add(employee); } public void addAccount(BeenzAccount account) { for (int i = 0; i < employees.size(); i++) { if (account.getAccountID() == this.accounts.get(i).getAccountID()) { System.out.println("Sorry this account already exists in the program"); return; } } this.accounts.add(account); }

public int getProgramID() { return programID; }

public void setProgramID(int programID) { this.programID = programID; }

public String getName() { return name; }

public void setName(String name) { this.name = name; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!