Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Kristófer Smári Leifsson
- // Forritun 01FEB Pre-Lab.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include<iostream>
- #include<time.h>
- #include<string>
- using namespace std;
- class dice
- {
- public:
- virtual void roll()
- {
- cout << "ERROR" << endl;
- }
- protected:
- int tvaerhlidar = rand() % 2 + 1;
- int rps = rand() % 3 + 1; //
- int sexhlidar = rand() % 6 + 1;
- };
- class crps : public dice
- {
- public:
- void roll()
- {
- if (rps == 1)
- cout << "rock" << endl;
- else if (rps == 2)
- cout << "paper" << endl;
- else if (rps == 3)
- cout << "sissors" << endl;
- }
- };
- class ctvaerhlidar : public dice
- {
- public:
- void roll()
- {
- if (tvaerhlidar == 1)
- {
- cout << "Heads" << endl;
- }
- else if (tvaerhlidar == 2)
- {
- cout << "Tails" << endl;
- }
- }
- };
- class csexhlidar : public dice
- {
- public:
- void roll()
- {
- cout << sexhlidar << endl;
- }
- };
- void prenta(dice& throwing, dice& mix, dice& display)
- {
- for (int i = 1; i < 11; i++)
- {
- int sinnum = rand() % 3 + 1;
- if (sinnum == 1)
- {
- throwing.roll();
- }
- else if (sinnum == 2)
- {
- mix.roll();
- }
- else if (sinnum == 3)
- {
- display.roll();
- }
- }
- }
- int main()
- {
- system("chcp 1252 > nul");
- srand(time(NULL));
- dice *ax, *bx, *cx;
- ctvaerhlidar a;
- crps b;
- csexhlidar c;
- ax = &a;
- bx = &b;
- cx = &c;
- prenta(*ax, *bx, *cx);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement