// ENGR 131, Monday 3:30 Recitation (Amanda Rohn)
// HW 10 - Checking Account class
// (Solution)

// File: checking.cpp
// Contains implementations of member functions for classes 
//	Checking and Transaction


#include "checking.h"
#include <cassert>
#include <vector>

Transaction::Transaction()
{
	amount = 0.0;
	type =  'D';
}

Transaction::Transaction(double money)
{
	amount = money;
	if(amount < 0.0)
		type = 'W';
	else
		type = 'D';
}

Transaction::~Transaction()
{
}


double Transaction::getAmount()
{
	return amount;
}

char Transaction::getType()
{
	return type;
}



Checking::Checking()
{
	balance = 0.0;
}

Checking::Checking(double initmoney)
{
	balance = initmoney;
}

Checking::~Checking()
{
}

double Checking::getBalance()
{
	return balance;
}

Transaction Checking::getTrans(int num)
{
	return history[num];
}

void Checking::Deposit(double money)
{
	assert(money > 0);
	balance += money;
	Transaction added(money);
	history.push_back(added);
}

void Checking::Withdraw(double money)
{
	assert(money > 0);
	balance -= money;
	Transaction added(-money);
	history.push_back(added);
}