Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming and logic 1: Java Attached Files: This is an exercise in creating an

ID: 3836143 • Letter: P

Question

Programming and logic 1: Java

Attached Files:

This is an exercise in creating an aggregation of objects similar to the aggregation discussed and reviewed using the chapter_6 zip file, I want you to do something similar per the following UML diagrams. I will provide you with a program to test your files with. Neither the class variables nor the methods are static (ie. leave out the static modifier).

*** I do not know how to upload files so I copied and paste file below*****

BusinessAccountTester.java

public class BusinessAccountTester {
public static void main(String[] args) {
  
Account acct_1 = new Account();
acct_1.setType("Checking");
acct_1.setNumber("4332 7789 4223 0987");
acct_1.setBalance(4250.00);

Account acct_2 = new Account();
acct_2.setType("Savings");
acct_2.setNumber("6543 2231 5432 7088");
acct_2.setBalance(3475.99);

Business bus_1 = new Business();
bus_1.setName("Joe's Pizza");
bus_1.setType("Food");
bus_1.setAcct(acct_2);

Business bus_2 = new Business();
bus_2.setName("Carl's Excavating");
bus_2.setType("Landscaping");
bus_2.setAcct(acct_1);
  
System.out.println("Now output the instance variable values for the 2 Businesses ");
System.out.println(bus_1.toString());
System.out.println();
System.out.println(bus_2.toString());
System.out.println(" Thank you for your patience");
  
}
}

Explanation / Answer

Please create the files and copy the following code in corresponding files.

Account.java

public class Account {
private String type;
private String number;
private Double balance;
public Account() {
  
}
public String getType() {
return this.type;
}
public void setType(String pTyp) {
this.type = pTyp;
}
public String getNumber() {
return this.number;
}
public void setNumber(String pNbr) {
this.number = pNbr;
}
public Double getBalance() {
return this.balance;
}
public void setBalance(Double pBal) {
this.balance = pBal;
}
public String toString() {
return "Account type is" + getType() + ", its number is "+ getNumber()
+ " and its balance is "+ getBalance();
}
}

Business.java

public class Business {
private String name;
private String type;
private Account acct;
public Business() {
  
}
public String getName() {
return this.name;
}
public void setName(String pName) {
this.name = pName;
}
public String getType() {
return this.type;
}
public void setType(String pType) {
this.type = pType;
}
public Account getAcct() {
return this.acct;
}
public void setAcct(Account pAcct) {
this.acct = pAcct;
}
public String toString() {
return "Business name is " + getName() + ", its type is "+ getType() + " and its account details are :"
+ getAcct().toString();
}
}