Question: java programming Account protected String name; protected ArrayList stocks; protected double balance; + Account ( String name, double balance) //stocks = new ArrayList () ;
java programming
Account protected String name; protected ArrayListstocks; protected double balance; + Account ( String name, double balance) //stocks = new ArrayList () ; + get and set property for name; get method for balance + void buyStock(String symbol, int shares, double unitPrice ) //update corresponding balance and stocks ( stocks.add(new Stock(..)); ) + deposit(double amount) : double //returns new balance + withdraw(double amount) : double //returns new balance + toString() : String
/*Stock class*/ public class Stock { public String symbol; public int shares; public Stock(String s, int n){symbol = s; shares = n;} @Override public String toString(){ return symbol + ": " + shares + " Shares"; } }
MarginAccount - debit : double - apr : double //.05 is for 5% interest rate + MarginAccount ( String name, double balance, double debit, double apr) + getDebit() : double + pay4Debit(double amount) : double//returns updated debit + addMonthlyInterest() : void + toString() : String
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
