Summary Files Commits Branches @commit @diff @stats
path: root / Year 1 / Object-oriented Programming / 12-Practice-17.05.2022 / ex1 / Player.h
diff options
context:
space:
mode:
1 files changed, 29 insertions, 0 deletions
-rw-r--r--Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex1/Player.h29
diff --git a/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex1/Player.h b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex1/Player.h
new file mode 100644
index 0000000..e57eea2
--- /dev/null
+++ b/Year 1/Object-oriented Programming/12-Practice-17.05.2022/ex1/Player.h
@@ -0,0 +1,29 @@
+enum Star {
+ One = 128,
+ Two = 256,
+ Three = 512,
+ Four = 1024,
+ Five = 2048,
+};
+
+class Player {
+protected:
+ int ID;
+ short points;
+ Star star;
+
+public:
+ Player() {
+ ID = 0;
+ points = 0;
+ star = One;
+ }
+ virtual bool levelUp() {
+ bool can = star < Five && points >= (star << 1);
+ if (can) {
+ star = (Star)(star << 1);
+ points -= star;
+ }
+ return can;
+ }
+};