This repository has been archived by the owner on Aug 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Seeder.cpp
94 lines (75 loc) · 2.33 KB
/
Seeder.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
//
// Created by Penultimate-Panacea on 8/27/2018.
//
#include "Seeder.h"
#include <string>
#include <iostream>
unsigned long concatenate(unsigned long i, unsigned long j) { //SOURCE : https://stackoverflow.com/a/37536245
std::string result;
for (; i <= j; ++i)
result += std::to_string(i);
return static_cast<unsigned long>(std::stoi(result));
}
unsigned short Seeder::getHall() const {
return hall;
}
void Seeder::setHall(unsigned short hall) {
Seeder::hall = hall;
}
unsigned short Seeder::getFloor() const {
return floor;
}
void Seeder::setFloor(unsigned short floor) {
Seeder::floor = floor;
}
unsigned short Seeder::getRoom() const {
return room;
}
void Seeder::setRoom(unsigned short room) {
Seeder::room = room;
}
unsigned short Seeder::getWall() const {
return wall;
}
void Seeder::setWall(unsigned short wall) {
Seeder::wall = wall;
}
unsigned short Seeder::getShelf() const {
return shelf;
}
void Seeder::setShelf(unsigned short shelf) {
Seeder::shelf = shelf;
}
unsigned short Seeder::getBook() const {
return book;
}
void Seeder::setBook(unsigned short book) {
Seeder::book = book;
}
Seeder::Seeder(unsigned short hall, unsigned short floor, unsigned short room, unsigned short wall, unsigned short shelf,
unsigned short book) : hall(hall), floor(floor), room(room), wall(wall), shelf(shelf), book(book) {}
Seeder::~Seeder() = default;
std::ostream &operator<<(std::ostream &os, const Seeder &Seeder) {
os << "h-" << Seeder.hall << "-f-" << Seeder.floor << "-r-" << Seeder.room << "-w-" << Seeder.wall << "-s-" << Seeder.shelf <<
"-b-" << Seeder.book;
return os;
}
unsigned long Seeder::getSeed() const {
return seed;
}
void Seeder::setSeed() {
unsigned long tempSeed;
unsigned long finalSeed;
tempSeed = concatenate(this->hall, this->floor);
std::cerr << "Hall|Floor CONCAT "<< tempSeed;
tempSeed = concatenate(tempSeed, this->room);
std::cerr << "PREV|Room CONCAT "<< tempSeed;
tempSeed = concatenate(tempSeed, this->wall);
std::cerr << "PREV|Wall CONCAT "<< tempSeed;
tempSeed = concatenate(tempSeed, this->shelf);
std::cerr << "PREV|Shelf CONCAT "<< tempSeed;
tempSeed = concatenate(tempSeed,this->book);
std::cerr << "PREV|Book CONCAT "<< tempSeed;
finalSeed = tempSeed;
Seeder::seed = finalSeed;
}