<repo_name>acc-cosc-1337-spring-2020/acc-cosc-1337-spring-2020-ChelliBean<file_sep>/test/examples_test/04_module_test/04_module_tests.cpp
#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
#include "bank_account.h"
#include "checking_account.h"


using std::unique_ptr; using std::make_unique;



TEST_CASE("Verify Test Configuration", "verification") {
	REQUIRE(true == true);
}

TEST_CASE("Test BankAccount constructor")
{
	BankAccount account(500);

	REQUIRE(account.get_balance() == 500);
}

TEST_CASE("Test Bank account deposit")
{
	BankAccount account(500);

	REQUIRE(account.get_balance() == 500);

	account.deposit(50);
	REQUIRE(account.get_balance() == 550);

	REQUIRE_THROWS_AS(account.deposit(-50), Invalid);
	REQUIRE(account.get_balance() == 550);
}

TEST_CASE("Test BankAccount withdraw")
{
	BankAccount account(500);
	REQUIRE(account.get_balance() == 500);

	account.withdraw(50);
	REQUIRE(account.get_balance() == 450);

	REQUIRE_THROWS_AS(account.withdraw(-1), Invalid);
	REQUIRE(account.get_balance() == 450);

	REQUIRE_THROWS_AS(account.withdraw(451), Invalid);
	REQUIRE(account.get_balance() == 450);
}

TEST_CASE("Verify Test Configuration", "verification") {
	REQUIRE 
}


TEST_CASE("Test CheckingAcount constructor")
{
	CheckingAccount account(500);
	REQUIRE(account.get_balance() == 512);

}

TEST_CASE("Test CheckingAccount get balance")
{
	CheckingAccount account(150);
	REQUIRE(account.get_balance() == 153);

}<file_sep>/src/homework/tic_tac_toe/tic_tac_toe_3.h
//h
#ifndef TICTACTOE3_H
#define TICTACTOE3_H
#include"tic_tac_toe.h"

class TicTacToe3 : public TicTacToe
{
public:
	//TicTacToe3();
	TicTacToe3(std::vector<string> p, string winner);
	TicTacToe3(): TicTacToe(3){}

	
	
private:
	bool check_column_win();
	bool check_row_win();
	bool check_diagonal_win();

};

#endif <file_sep>/src/homework/tic_tac_toe/tic_tac_toe_data.h
//h
#include "tic_tac_toe.h"

class TicTacToeData : public TicTacToe
{
public:
	void save_games(const std::vector<std::unique_ptr<TicTacToe>>& games);

	std::vector<std::unique_ptr<TicTacToe>> get_games();



};<file_sep>/src/homework/tic_tac_toe/tic_tac_toe_data.cpp
#include "tic_tac_toe_data.h"
#include"tic_tac_toe.h"
#include<fstream>
#include<iostream>


//cpp

void TicTacToeData::save_games(const std::vector<std::unique_ptr<TicTacToe>>& games)
{
	
	ofstream file("tictactoe.txt");

	for (auto p : pegs)
	{
		file << p;
	}
	file << get_winner();
	file.close();
}

std::vector<std::unique_ptr<TicTacToe>> TicTacToeData::get_games()
{
	std::vector<std::unique_ptr<TicTacToe>>boards;
	
	ofstream vecFile("boards.txt");

	return std::vector<std::unique_ptr<TicTacToe>>();
}
<file_sep>/src/homework/tic_tac_toe/tic_tac_toe.cpp
#include "tic_tac_toe.h"
//cpp
using std::cout;

TicTacToe::TicTacToe(std::vector<string> p, string win)
	:pegs{p}, winner{win}
{
}

bool TicTacToe::game_over()
{
	if (check_column_win() == true || check_diagonal_win() == true || check_row_win() == true)
	{
		set_winner();
		return true;
	}
	else if(check_board_full() == true)
	{
		winner = "C";
		return true;
	}
	else
	{
		return false;
	}
}

void TicTacToe::start_game(std::string first_player)
{
	if (first_player == "X" || first_player == "O")
	{
		player = first_player;
	}
	else
	{
		throw Error("X's or O's only!");
	}

	

	clear_board();
}

void TicTacToe::mark_board(int position)
{
	if(position < 1 || position > 9 && pegs.size() == 9)
	{
		throw Error("Out of range");
	}
	if (position < 1 || position > 16 && pegs.size() == 16)
	{
		throw Error("Out of range");
	}
	else if(player =="")
	{
		throw Error("Must start game first.");
	}

	pegs[position - 1] = player;
	set_next_player();

}

void TicTacToe::set_next_player()
{
	if(player =="X")
	{
		player = "O";
	}
	else if (player == "O")
	{
		player = "X";
	}
	
}

bool TicTacToe::check_board_full()
{
	for (std::size_t i = 0; i < pegs.size(); ++i)
	{
		if (pegs[i] == " ")
		{
			return false;
		}
	}
	return true;
}

void TicTacToe::clear_board()
{
	for (auto &peg : pegs)
	{
		peg = " ";
	}
}


bool TicTacToe::check_column_win()
{
	return false;
}

bool TicTacToe::check_row_win()
{
	return false;
}

bool TicTacToe::check_diagonal_win()
{
	return false;
}

void TicTacToe::set_winner()
{
	if (player == "X")
	{
		winner = "O";
	}
	else
	{
		winner = "X";
	}
}

std::ostream & operator<<(std::ostream & out, const TicTacToe & t)
{
	for (std::size_t i = 0; i < t.pegs.size(); i += sqrt(t.pegs.size()))
	{
		out << t.pegs[i] << "|" << t.pegs[i + 1] << "|" << t.pegs[i + 2];

		if (t.pegs.size() == 16)
		{
			out << "|" << t.pegs[i + 3];
		}

		out << "\n";
	}
	return out;
}

std::istream & operator>>(std::istream & in, TicTacToe & b)
{
	// TODO: insert return statement here
	try
	{
		int position;
		cout << "\n";
		cout<< "Pick a spot on the board (1-9): " << "\n";
		in >> position;
		cout << "\n";
		b.mark_board(position);
		cout << "\n";
	}
	catch (Error e)
	{
		cout << e.get_message() << "\n";
	}
	return in;
}
<file_sep>/src/examples/11_module/03_memory_leak/memory_leak.h
//create memory leak function
void memory_leak
<file_sep>/src/examples/02_module/02_if_else/if_else.h
//write include statement
#include<string>

using std :: string; 

//write prototype for function named get_generation that accepts an int and
//returns a string
string get_generation(int year);


<file_sep>/src/examples/03_module/06_vectors/vec.h
#include<string>
#include<vector>

/*
Write function prototype for function loop_vector_w_index with no parameters.

*/


/*
Write function prototype for function loop_vector_w_index with a vector of int pass by value parameter.

*/
void loop_vector_w_index(std::vector <int> nums); 


/*
Write function prototype for function loop_vector_w_index with a vector of int pass by reference parameter.  Loop can modify
*/
void loop_vector_w_index_ref(std::vector <int> &nums);

/*
Write function prototype for function loop_vector_w_index with a vector of int const pass by reference parameter. Loop cannot modify
*/
void loop_vector_w_index_ref_const(const std::vector <int> &nums);

void loop_vector_w_auto(std::vector<int> &nums);
void loop_vector_w_auto_ref(std::vector<int> &nums);
void loop_vector_w_auto_const(const std::vector<int> &nums);

<file_sep>/test/homework_test/04_vectors_test/04_vectors_tests.cpp
#define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
#include "catch.hpp"
#include "vectors.h"

TEST_CASE("Verify Test Configuration", "verification") {
	REQUIRE(true == true);
}
TEST_CASE("Verify max")
{
	std::vector<int>numbers{ 8, 4, 20, 88, 66, 99 };
	get_max_from_vector(numbers);
	REQUIRE(get_max_from_vector(numbers) == 88);
}

TEST_CASE("Verify primes")
{
	std::vector<int>primes1{2, 3};
	std::vector<int>primes2{2, 3, 5, 7 };
	std::vector<int>primes3{2, 3, 5, 7, 11, 13 };

	REQUIRE(vector_of_primes(5) == primes1);
	REQUIRE(vector_of_primes(9) == primes2);
	REQUIRE(vector_of_primes(14) == primes3);
}

TEST_CASE("Verify is prime")
{
	REQUIRE(is_prime(7) == true);
	REQUIRE(is_prime(10) == false);
	REQUIRE(is_prime(-7) == false);
}<file_sep>/src/classwork/05_assign/main.cpp
//write include statemetns
#include<iostream>
#include "rectangle.h"
#include<vector>
using std::cout;

/*
Create a vector of rectangles
Add 3 Rectangle classes to the vector:
Width	Height		Area
  4		 5			  20
 10		10			 100
100		10			1000
Iterate the vector and display the Area for each Rectangle on one line and the total area for the
3 rectangles.
*/
int main()
{
	std::vector<Rect> area { Rect(4, 5), Rect(10, 10), Rect(100, 10) };

	auto total{ 0 };

	for(auto x: area)
	{
		cout << x << "\n";


	}
	/*
	for (auto x : area)
	{
		cout << x.get_area() << "\n";
		total += x.get_area();
	}

	cout << total;
	*/
	return 0;
}
<file_sep>/src/examples/11_module/01_ref_pointers/ref_pointers.h
//Create ref function w reference and pointer parameter 

void ref_pointers(int1, int*int2);

//Create return pointer function<file_sep>/src/examples/04_module/01_bank/atm.cpp
//atm.cpp
#include "atm.h"

std::ostream & operator<<(std::ostream & out, const ATM & a)
{
	a.customer.display_accounts();

	return out;
}<file_sep>/src/examples/04_module/01_bank/atm.h
//atm.h
#ifndef ATM_H
#define ATM_H
#include "customer.h"

class ATM
{
public:
	ATM(Customer& c) : customer(std::move(c)){}
	friend std::
};<file_sep>/src/examples/04_module/01_bank/main.cpp
#include "bank_account.h"
#include "checking_account.h"
#include"savings_account.h"
#include"customer.h"
#include<iostream>
#include<vector>
#include<string>
#include<memory>

using std::cout; using std::cin;
using std::unique_ptr; using std::make_unique;

int main()
{
	/*
	//c++ 98
	SavingsAccount*s = new SavingsAccount(500);
	//more lot of code
	delete s;
	s = nullptr;*/

	//c++ 11
	
	unique_ptr<BankAccount> s = make_unique<SavingsAccount> ( 90 );
	unique_ptr<BankAccount> c = make_unique<CheckingAccount> ( 100 );
	
	
	std::vector<unique_ptr<BankAccount>> accounts;
	accounts.push_back(std::move(s));
	accounst.push_back(std::move(c));

	for (auto &act : accounts)
	{
		cout << act->get_balance() << "\n";
	}

	

	/*
	BankAccount* act=new CheckingAccount(100);

	BankAccount account(500);
	Customer cust;
	cust.add_account(account);

	/*

	do you want to play again loop
	Ttt game;

	loop for mark board

	game ends
	call manager save game

	*/
	
	cin >> account;
	cout << account;
	display_balance(account);

	/*std::vector<BankAccount> accounts{ BankAccount(100), BankAccount(200) };

	for (auto act : accounts)
	{
		cout << act.get_balance() << "\n";
	}
	*/

	auto balance = account.get_balance();
	cout << "Balance is: " << balance << "\n";

	auto amount{ 0 };
	cout << "Enter deposit amount: \n";
	cin >> amount;

	try
	{
		account.deposit(amount);
		cout << "Balance is: \n" << account.get_balance;
	}
	catch (Invalid e)
	{
		cout << e.get_error() << "\n";
	}

	return 0;
}<file_sep>/src/homework/03_iteration/main.cpp
//write include statements
#include<iostream>
#include "dna.h"
#include <string>
//write using statements
using std::cout; using std::cin; using std::string;

/*
Write code that prompts user to enter 1 for Get GC Content, 
or 2 for Get DNA Complement.  The program will prompt user for a 
DNA string and call either get gc content or get dna complement
function and display the result. Program runs as long as 
user enters a y or Y.
*/
int main() 
{
	int starter;
	
	int choice;

	do
	{
		cout << "Enter 1 for GC content or 2 for DNA complement: ";
		cin >> starter;

		if (starter == 1)
		{
			string dna1;

			cout << "Enter a DNA sequence: ";
			cin >> dna1;

			get_gc_content(dna1);

			double gcContent = get_gc_content(dna1);

			cout << "Content of G's and C's is:  " << gcContent;
		}
		else if (starter == 2)
		{
			string dna2;

			cout << "Enter a DNA sequence: ";
			cin >> dna2;

			get_dna_complement(dna2);

			string dnaComp = get_dna_complement(dna2);

			cout << "DNA complement is:  " << dnaComp;
		}
		else
		{
			cout << "Invalid entry";
		}

		cout << "Type 1 to continue...";
		cin >> choice;

	} while (choice == 1);

	return 0;
}<file_sep>/src/examples/09_module/temperature_data.h
//temperature_data.h
#include"temperature.h"
#ifndef TEMPERATURE_DATA_H
#define TEMPERATURE_DATA_H
#include<fstream>
#include<string>
#include<vector>

class TemperatureData
{
public:
	void save_tenos(std::vector<Temperature>& ts);
	std::vector<Temperature>get_temps()const;
	
private:
	const std::string file_name{ "temperature.dat" };
};



#endif // !TEMPERATURE_DATA_H
<file_sep>/src/homework/tic_tac_toe/tic_tac_toe_manager.cpp
#include "tic_tac_toe_manager.h"
#include"tic_tac_toe.h"
#include<iostream>

using std::cout; using std::cin;

//cpp

/*void TicTacToeManager::save_game(const TicTacToe b)
{
	games.push_back(b);
	update_winner_count(b.get_winner());
}*/

void TicTacToeManager::save_game(std::unique_ptr<TicTacToe>& b)
{
	update_winner_count(b->get_winner());
	games.push_back(std::move(b));
}

void TicTacToeManager::get_winner_total(int & x, int & o, int & t)
{
	o = o_win;
	x = x_win;
	t = ties;
}

void TicTacToeManager::update_winner_count(std::string winner)
{
	if (winner == "X")
	{
		x_win ++;
	}
	else if (winner == "O")
	{
		o_win ++;
	}
	else
	{
		ties ++;
	}
}

std::ostream & operator<<(std::ostream & out, const TicTacToeManager & manager)
{
	// TODO: insert return statement here
		out << "All games played: \n";

		for (auto& game : manager.games)
		{
			out << "\n";
			out << *game;
			std::string w = game->get_winner();
			out << "\n";
			out << "the winner is: " << w << "\n";
		}

		out << "The winner is X " << manager.x_win << "\n";
		out << "The winner is O " << manager.o_win << "\n";
		out << "It's a tie " << manager.ties << "\n";
		
		return out;
}
<file_sep>/README.md
[![Build Status](https://travis-ci.org/acc-cosc-1337-spring-2020/acc-cosc-1337-spring-2020-ChelliBean.svg?branch=master)](https://travis-ci.org/acc-cosc-1337-spring-2020/acc-cosc-1337-spring-2020-ChelliBean)

# acc-cosc-1337-starter
# CHELLIBEAN
#Merp
C++ starter code with CMake 
<file_sep>/src/examples/04_module/01_bank/customer.h
//customer.h
#ifndef CUSTOMER_H //header guards
#define CUSTOMER_H //use bc errors will occur if you try to use customer more than once
#include<vector>
#include"bank_account.h"

class Customer
{
public:
	void add_account(BankAccount& act);
	void display_accounts()const;

private:
	std::vector<BankAccount> accounts;
};

#endif // !CUSTOMER_H<file_sep>/src/homework/tic_tac_toe/tic_tac_toe_manager.h
//h
#include"tic_tac_toe.h"
#include"tic_tac_toe_data.h"
#include<vector>
//#include<iostream>
#include<memory>
#ifndef TICTACTOEMANAGER_H
#define TICTACTOEMANAGER_H

class TicTacToeManager//:public TicTacToe
{
public:
	TicTacToeManager() = default;

	void save_game(std::unique_ptr<TicTacToe> &b);
	friend std::ostream& operator<<(std::ostream& out, const TicTacToeManager & manager);
	void get_winner_total(int& x, int& o, int& t);

private:
	std::vector<std::unique_ptr<TicTacToe>> games{};
	
	int x_win{ 0 };
	int o_win{ 0 };
	int ties{ 0 };
	void update_winner_count(std::string winner);

	int data;
};
#endif // !MANAGER_H
<file_sep>/src/homework/04_vectors/main.cpp
#include "vectors.h"
#include<iostream>
#include<vector>

using std::cout; using std::cin;
/*
use a vector of int with values 8, 4, 20, 88, 66, 99

Prompt user for 1 for Get Max from vector and 2 for Get primes.
Prompt user for a number and return max value or list of primes
and display them to screen.
Program continues until user decides to exit.

*/
int main()
{
	std::vector<int>numbers{ 8, 4, 20, 88, 66, 99 };
	int starter = 0;
	int num;
	char keepGoing = 'y';

	do
	{
		cout << "Enter 1 for get max or enter 2 for get primes " << "\n";
		cin >> starter;

			if (starter == 1)
			{
				get_max_from_vector(numbers);
				cout << get_max_from_vector(numbers) << "\n";

				cout << "y to continue: ";
				cin >> keepGoing;
			}
			else if (starter == 2)
			{
				cout << "Enter a number greater than 0: ";
				cin >> num;
				std::vector<int>prime = vector_of_primes(num);

				for (auto n : prime)
				{
					cout << n << ", " << "\n";
				}

				cout << "y to continue: ";
				cin >> keepGoing;
			}
	} while (starter == 0 || keepGoing == 'y');

	return 0;
}