This is an exercise in creating an aggregation of objects similar to the aggrega
ID: 3836024 • Letter: T
Question
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).
Account Business String type String name String number String type Double balance Account acct Constructor(s) Constructor(s) String getType() String getName void setType(String pTyp) void setName (String pNme String getNumber void setNumber (String pNbr) String getType() Double getBalance() void setType(String pTyp) void setBalance ble pBal) Account getAcct() pAcct) String toString() void setAcct Account String to StringExplanation / Answer
Account.java:
class Account
{
String type;
String number;
double balance;
public Account(String type, String number, double balance)
{
this.type = type;
this.number = number;
this.balance = balance;
}
public String getType() { return type; }
public void setType(String pTyp) { type = pTyp; }
public String getNumber() { return number; }
public void setNumber(String pNbr) { number = pNbr; }
public double getBalance() { return balance; }
public void setBalance(double pBal) { balance = pBal; }
public String toString()
{
return "Type: " + type + " Number: " + number + " Balance: " + balance;
}
}
Business.java:
class Business
{
String name;
String type;
Account acct;
public Business(String nm, String typ, Account acc)
{
name = nm;
type = typ;
acct = acc;
}
public String getName()
{
return name;
}
public void setName(String pNme)
{
name = pNme;
}
public String getType()
{
return type;
}
public void setType(String pTyp)
{
type = pTyp;
}
public Account getAcct()
{
return acct;
}
public void setAcct(Account pAcct)
{
acct = pAcct;
}
public String toString()
{
return "Name: " + name + " Type: " + type + "Account: " + acct;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.