-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbowl.cpp
108 lines (85 loc) · 2.44 KB
/
bowl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
// bowl.cpp
// bug-cup-draw
//
// Created by Eduardo Castro on 22/12/21.
//
#ifndef BOWL_CPP
#define BOWL_CPP
#include <iostream>
#include <cstdlib>
#include <time.h>
#include "list.cpp"
using namespace std;
template<class T>
class Bowl {
private:
List<T> *bowl1;
List<T> *bowl2;
List<T> *bowl3;
List<T> *bowl4;
List<T> *bowl5;
public:
Bowl(){
this->bowl1 = new List<T>();
this->bowl2 = new List<T>();
this->bowl3 = new List<T>();
this->bowl4 = new List<T>();
this->bowl5 = new List<T>();
}
void setBowl1(T *data){
this->bowl1->addLast(data);
}
void setBowl2(T *data){
this->bowl2->addLast(data);
}
void setBowl3(T *data){
this->bowl3->addLast(data);
}
void setBowl4(T *data){
this->bowl4->addLast(data);
}
void setBowl5(T *data){
this->bowl5->addLast(data);
}
int getCount(){
return bowl1->getCount() + bowl2->getCount() + bowl3->getCount() + bowl4->getCount() + bowl5->getCount();
}
int getCountBowl1(){
return bowl1->getCount();
}
int getCountBowl2(){
return bowl2->getCount();
}
int getCountBowl3(){
return bowl3->getCount();
}
int getCountBowl4(){
return bowl4->getCount();
}
int getCountBowl5(){
return bowl5->getCount();
}
T *sortData(int bowl){
int number;
srand(time(0));
switch (bowl) {
case 1:
number = rand() % getCountBowl1();
return this->bowl1->removeAt(number);
case 2:
number = rand() % getCountBowl2();
return this->bowl2->removeAt(number);
case 3:
number = rand() % getCountBowl3();
return this->bowl3->removeAt(number);
case 4:
number = rand() % getCountBowl4();
return this->bowl4->removeAt(number);
default:
number = rand() % getCountBowl5();
return this->bowl5->removeAt(number);
}
}
};
#endif