rendered paste body#include "dice.h"
#include <iostream>
#include <cTime>
#include <cstdlib>
dice::dice(int diceSides, int diceTosses) {
myDiceSides = diceSides;
myDiceTosses = diceTosses;
}
dice::~dice()
{
}
// Get-Metoder
int dice::getNrOfSides() {
return myDiceSides;
}
int dice::getNrOfValue() {
return myDiceValue;
}
// Set-Metoder
void dice::setDiceTosses(int diceTosses) {
srand((unsigned)time(NULL));
for(int i=0; i<myDiceTosses; i++) {
myDiceValue = rand()%6+1;
cout <<"lowl"<< myDiceValue;
}
}
void dice::showInfo() {
cout <<"Antal sidor: "<<myDiceSides<<endl;
cout <<"Antal kast: "<<myDiceTosses<<endl;
}
#pragma once
#include <string>
using namespace std;
class dice
{
private:
int myDiceSides;
int myDiceValue;
int myDiceTosses;
public:
dice(int diceSides, int diceTosses);
~dice(void);
int getNrOfSides();
int getNrOfValue();
void setDiceTosses(int diceTosses);
void showInfo();
};
#include "dice.h"
#include <iostream>
using namespace::std;
int main() {
int diceTosses;
dice d1(6, 15);
dice d2(35, 100);
d1.showInfo();
d2.showInfo();
}