HW2 Publish
This commit is contained in:
20
include/Snack.hpp
Normal file
20
include/Snack.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef SNACK_HPP
|
||||
#define SNACK_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
class Snack {
|
||||
public:
|
||||
Snack(std::string snackName);
|
||||
Snack(std::string snackName, int snackAmount);
|
||||
|
||||
[[nodiscard]] std::string getName() const;
|
||||
[[nodiscard]] int getAmount() const;
|
||||
void setAmount(int snackAmount);
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
int amount;
|
||||
};
|
||||
|
||||
#endif
|
||||
42
include/Storage.hpp
Normal file
42
include/Storage.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef STORAGE_HPP
|
||||
#define STORAGE_HPP
|
||||
|
||||
#include "Snack.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
enum class StorageType {
|
||||
CANDY,
|
||||
COOKIES,
|
||||
CAKE,
|
||||
OTHER
|
||||
};
|
||||
|
||||
class Storage {
|
||||
public:
|
||||
Storage(StorageType storageType);
|
||||
Storage(StorageType storageType, int storageCapacity);
|
||||
|
||||
void add(std::string snackName);
|
||||
void add(std::string snackName, int snackAmount);
|
||||
void eat(std::string snackName, int snackAmount);
|
||||
void eatFirst(int snackAmount);
|
||||
void eatLast(int snackAmount);
|
||||
void sortByAmount();
|
||||
void sortBySnackName();
|
||||
void clear();
|
||||
|
||||
[[nodiscard]] int getAmount() const;
|
||||
[[nodiscard]] int getCapacity() const;
|
||||
[[nodiscard]] StorageType getType() const;
|
||||
[[nodiscard]] const std::vector<Snack> &getSnacks() const;
|
||||
|
||||
void setCapacity(int storageCapacity);
|
||||
|
||||
private:
|
||||
std::vector<Snack> snacks;
|
||||
StorageType type;
|
||||
int amount;
|
||||
int capacity;
|
||||
};
|
||||
#endif
|
||||
19
include/StorageManager.hpp
Normal file
19
include/StorageManager.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef STORAGEMANAGER_HPP
|
||||
#define STORAGEMANAGER_HPP
|
||||
|
||||
#include "Storage.hpp"
|
||||
|
||||
class StorageManager {
|
||||
public:
|
||||
StorageManager();
|
||||
|
||||
void AddAllStorageCapacity(int capacity);
|
||||
void moveCapacity(StorageType fromType, StorageType toType, int moveCapacity);
|
||||
|
||||
[[nodiscard]] std::vector<Storage>& getStorages();
|
||||
|
||||
private:
|
||||
std::vector<Storage> storages;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user