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

CreditCard _name: String _spendings: List _balance: double +Credict card(string

ID: 3574023 • Letter: C

Question

CreditCard _name: String _spendings: List _balance: double +Credict card(string name)//initialize spendings [], balance to 0 + getname(): string +setName(string name): void +addtransaction(transaction t)://update_spendings_balance +getbalance(): double +tostring(): string(a string representation for name and balance) Transaction +amount: double +category: int +transaction (double d, int c) Milageawardcard _points: double +milageawardcard(string name)//initialize spendings, balance, and _points to proper value + addtransaction(transcation t)://update_spendings, _balance, and _points +tostring(): string(a string representation for name balance) # 3 methods will be added on wed.

Explanation / Answer


public class Transaction {
  
   double amount;
   int category;
  
   Transaction(double d, int c){
       this.amount = d;
       this.category = c;
   }

}
//-----------------------------------------------------------

import java.util.*;
public class CreditCard {

   String _name;
   List<Transaction> _spendings;
   double _balance;
  
   CreditCard(String name){
       this._balance = 0;
       this._name = name;
       this._spendings = new ArrayList<Transaction>();
              
   }
  
   public String getName(){
       return this._name;
   }
  
   public void setName(String name){
       this._name = name;
   }
  
   public void addTransaction(Transaction t){
       _spendings.add(t);
       this._balance+=t.amount;
      
   }
  
   public double getBalance(){
       return this._balance;
   }
  
   public String toString(){
       return this._name+" : "+String.valueOf(_balance);
   }
}
//------------------------------------------------------------------


public class MileageAwardCard extends CreditCard {
  
   double _points;
  
   public MileageAwardCard(String name) {
       // TODO Auto-generated constructor stub
       super(name);
       this._points = 0;
   }
  
   public void addTransaction(Transaction t){
       super.addTransaction(t);
       this._points++; //need a criteria to update points. Assumed 1 per transaction
   }
  
   public String toString(){
       return super.toString();
   }
}
//---------------------------------------------------

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote