Added VERY old code. Very cringy to look at, but hey, we all had to start somewhere...

This commit is contained in:
2018-01-08 23:37:31 -08:00
parent 7b18f6a807
commit df19ed7631
141 changed files with 26107 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
#include <iostream>
#include <string>
using namespace std;
int main(void){
unsigned char exit;
string response;
enum question{
first,
second,
third
} currentquestion = first;
while(exit != 1){
switch(currentquestion){
case first:
cout << "First Question: Which is NOT an internal component of a desktop computer?\n\nA: Ram Module\nB: Power Supply\nC: Hard Drive\nD: Monitor\nPlease enter your selection: ";
cin >> response;
if((response.compare("a") == 0) | (response.compare("A") == 0)){
cout << "\nIncorrect. Ram modules are an internal component.\nPlease try again..." << endl;
cout << string(2, '\n');
}else if((response.compare("b") == 0) | (response.compare("B") == 0)){
cout << "\nIncorrect. Power supplies are an internal component.\nPlease try again..." << endl;
cout << string(2, '\n');
}else if((response.compare("c") == 0) | (response.compare("C") == 0)){
cout << "\nIncorrect. Hard drives are an internal component.\nPlease try again..." << endl;
cout << string(2, '\n');
}else if((response.compare("d") == 0) | (response.compare("D") == 0)){
cout << "\nCorrect! Monitor's are external components on desktops." << endl;
cout << string(2, '\n');
currentquestion = second;
}else{
cout << "You have entered an invalid response, please try again..." << endl;
cout << string(2, '\n');
}
break;
case second:
cout << "Second Question: Which is a model number for an ivy bridge processor?\nA: i5-3570K\nB: i7-2600K\nC: i3-2120\nD: i5-2400\nPlease enter your selection: ";
cin >> response;
if((response.compare("a") == 0) | (response.compare("A") == 0)){
cout << "\nCorrect!. This is an ivy bridge processor!" << endl;
cout << string(2, '\n');
return 0;
}else if((response.compare("b") == 0) | (response.compare("B") == 0)){
cout << "\nIncorrect. This is a Sandy Bridge processor.\nPlease try again..." << endl;
cout << string(2, '\n');
}else if((response.compare("c") == 0) | (response.compare("C") == 0)){
cout << "\nIncorrect. This is a Sandy Bridge processor.\nPlease try again..." << endl;
cout << string(2, '\n');
}else if((response.compare("d") == 0) | (response.compare("D") == 0)){
cout << "\nIncorrect. This is a Sandy Bridge processor.\nPlease try again..." << endl;
cout << string(2, '\n');
}else{
cout << "\nYou have entered an invalid response, please try again..." << endl;
cout << string(2, '\n');
}
break;
default:
cerr << "You should never see this. There has been an enum error." << endl;
}
}
return 0;
}

View File

@@ -0,0 +1,13 @@
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include "rps.h"
using namespace std;
int main()
{
Rps game;
game.newgame();
return 0;
}

View File

@@ -0,0 +1,60 @@
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
class Player{
public:
friend class Rps;
Player(){
srand ( time(NULL) );
wins(0);
losses(0);
}
Player
string guess(){
int number;
number = ((int)(rand() * 10))%3;
if (number == 0){
return "Rock";
}
else if (number == 1){
return "Paper";
}
else if (number == 2){
return "Scissors";
}
else {
return "Dynamite";
}
}
string userguess(){
/*Extra Challenge 1:
Get User input for one of the guesses*/
}
string wunderguess(){
try{
SimpleSerial wunderboard("COM3", 9600);
string mystr = wunderboard.readLine();
cout << "Wunderboard says: " << mystr << endl;
}catch(boost::system::system_error& e){
cout << "Error. << e.what() << endl;
}
/*Extra Challenge 2:
Add the Players name to the object and it constructor. Add a function to get the name/change it*/
private:
int wins;
int losses;
};

View File

@@ -0,0 +1,61 @@
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include "player.h"
using namespace std;
class Rps{
public:
void newgame(){
/*Extra Challenge 5:
Make this program a 3 player game*/
Player player1;
Player player2;
string player1guess;
string player2guess;
/*Extra Challenge 3
Make this program Rock, Paper, Scissors, Lizard, Spock*/
/*Extra Challenge 4
Make this program best 2 out of 3*/
cout << "Welcome to RPS (Rock, Paper, Scissors) v1.0" << endl;
cout << "Preparing to run the guess() method on both player objects" << endl;
/*Extra Challenge 1
Get User input for one of the guesses*/
player1guess = player1.guess();
player2guess = player2.guess();
while (player1guess.compare(player2guess) == 0){
player1guess = player1.guess();
player2guess = player2.guess();
}
if ((player1guess.compare("Rock") == 0) && (player2guess.compare("Scissors") == 0) )
cout << "Player 1 smashes the heck out of player 2 with a rock! Die scissors die!" << endl;
if ((player1guess.compare("Scissors") == 0) && (player2guess.compare("Rock") == 0) )
cout << "Player 2 smashes the heck out of player 1 with a rock! Die scissors die!" << endl;
if ((player1guess.compare("Paper") == 0) && (player2guess.compare("Rock") == 0) )
cout << "Player 1 smothers player 2 with paper! Die rock die!" << endl;
if ((player1guess.compare("Rock") == 0) && (player2guess.compare("Paper") == 0) )
cout << "Player 2 smothers player 1 with paper! Die rock die!" << endl;
if ((player1guess.compare("Scissors") == 0) && (player2guess.compare("Paper") == 0) )
cout << "Player 1 slices and dices player 2 with scissors! Die paper die!" << endl;
if ((player1guess.compare("Paper") == 0) && (player2guess.compare("Scissors") == 0) )
cout << "Player 2 slices and dices player 1 with scissors! Die paper die!" << endl;
/*Extra Challenge 6
Actually declare a winner*/
}
/*Extra Challenge 7
Keep track of number of wins and number of losses for each object of this class*/
};