- useful class
- correct base class
- correct inheritance
- seperate header files
- useful virtual function
- useful polymorfism
- correct abstract base class
- no mistake in object-oriented programming
- useful member function
- useful member variabel
- correct protections
- getters and setters for member variables
- at least 2 default constructors
- at least 2 specific constructors
- at least 2 destructors
- useful container class
- useful Qt class
- clean main (i.e. nothing in the main that shoud be in a class)
- operator overloading
- useful pointer usage
- useful string usage
- dynamic memory allocation (new)
- dynamic memory removing (delete)
- at least 4 useful const
- at least 4 useful bool
- 2 unsigned chars or other better usage of memory efficient type
- template function or class
- 2 (modern) call-by-references
- everything in one or more self-made namespace(s)
- default values in function definition
- function overloading
- useful useage of this
- no globals, but statics if needed
- friend function or class
- maintanability by good function naming and/or comments everywhere
- useful usage of stringstreams
- using the correct type on a lot of places (almost everywhere possible)
- correctly using const on a lot of places (almost everywhere possible)
- correct useage of inline function
- useful recursive function
- non-type template arguments
- useful usage of nullptr
- useful usage of (modern) file-I/O
- correct usage of command line parameters
- useful usage of struct
- nesting of classes
- useful usage of union
- useful usage of enum
- multiple inheritance
- member initialization in constructors
- useful usage of signals/slots
- useful network communication
- useful usage of threads
- robust program that has been extensively tested (proof it)
- one complete project that compiles and does not crash
- usage of a GUI
- usage of OpenGL or other 3D engine
- useful usage of an external library
- project that works with hardware
- a nice extra that you think that should deserve grading (stuff you put time in and is not rewarded by an item above)
in game.h
class game {
friend class cupid;
public:
game();
~game();
unsigned char playersInGame();
void startGame();
Header files enough
in card.h
inline std::string roleToString(player *playerObj) const;
inline std::string roleToString(ROLE role) const;
in player.h
inline ROLE getRole() const { return this->role; }
void setRole(ROLE asignedRole) { this->role = asignedRole; }
void setLover(player &lover) { this->inLoveWith = &lover;}
std::string getName() const { return name; }
in player.h
private:
std::string name = "";
std::string passwd = "";
ROLE role = NA;
player *inLoveWith = nullptr;
bool major = 0;
bool isAI = 0;
bool isDead = 0;
unsigned char hang = 0;
in player.h
void setRole(ROLE asignedRole) { this->role = asignedRole; }
void setLover(player &lover) { this->inLoveWith = &lover;}
in card.h & hunter.h
class card {
public:
card();
class hunter {
public:
hunter();
in player.h
player(std::string name, std::string passwd, bool isAI)
: name(name), passwd(passwd), isAI(isAI) {}
in game.cpp
game::game() // constructor
{
mainMenu();
assignRole();
}
almost everywhere
Almost every class has a destructor, and there are at LEAST 2 classes.
in game.h
std::vector<player *> players;
in main.cpp
#include "global.h"
#include "game.h"
using namespace miller;
int main(/*int argc, char *argv[]*/)
{
srand((unsigned)time(NULL));
auto gameObj = new game;
#ifdef DEBUG
cout << "Players in game: "<< static_cast<int>(gameObj->playersInGame()) << endl;
#endif
gameObj->startGame();
delete gameObj;
return 0;
}
pointer everywhere
in player.h
std::string name = "";
std::string passwd = "";
in game.cpp
case '1': // sart game
gameStart = 1;
if (players.size() != 24) {
for (int i = 0; players.size() != 24; i++) {
string name = "AI " + to_string(i);
addPlayer(new player(name, name, 1));
}
}
break;
in game.cpp
game::~game() // deconstructor
{
for (unsigned int i = 0; i < players.size(); i++) { // Loop trough all the
delete players[i]; // created players and
} // free the memory.
#ifdef DEBUG
cout << "game::~game() at: " << this << endl;
#endif
}
in player.h
bool major = 0;
bool isAI = 0;
bool isDead = 0;
in game.h
protected:
bool time;
in game.h
void mainArt() const;
void playersArt(unsigned char players) const;
in player.h
inline ROLE getRole() const { return this->role; }
std::string getName() const { return name; }
almost everywhere in game.h
private:
struct InGame {
unsigned char townfolks = 0;
unsigned char werewolves = 0;
unsigned char witch = 0;
unsigned char thief = 0;
unsigned char little_girl = 0;
unsigned char hunter = 0;
unsigned char cupid = 0;
unsigned char seer = 0;
unsigned char sheriff = 0;
} ingame;
in everything
namespace miller { ... }
in card.h
inline std::string roleToString(player *playerObj = nullptr) const;
inline std::string roleToString(ROLE role = NA) const;
in player.h
inline ROLE getRole() { return this->role; }
void setRole(ROLE asignedRole) { this->role = asignedRole; }
void setLover(player &lover) { this->inLoveWith = &lover;}
in game.cpp
static player *major = nullptr;
if (players[tmp]->isAI == 1) {
game::gameHost();
}
in player.h
class player {
friend class game;
friend class card;
friend class cupid;
Tried to name functions so it says what they do.
in game.cpp
player &game::gameHost() // Assign the host/major label to a random player
{
unsigned char tmp = rand() % players.size();
#ifdef DEBUG
cout << "game::gameHost() trying to make " << players[tmp]->getName() << " a host" << endl;
#endif
static player *major = nullptr;
if (players[tmp]->isAI == 1) {
game::gameHost();
}
else
major = players[tmp];
#ifdef DEBUG
cout << major << endl;
#endif
return *major;
}
in card.h
inline std::string roleToString(player *playerObj = nullptr) const;
inline std::string roleToString(ROLE role = NA) const;
in player.h
player *inLoveWith = nullptr;
in game.h
struct InGame {
unsigned char townfolks = 0;
unsigned char werewolves = 0;
unsigned char witch = 0;
unsigned char thief = 0;
unsigned char little_girl = 0;
unsigned char hunter = 0;
unsigned char cupid = 0;
unsigned char seer = 0;
unsigned char sheriff = 0;
} ingame;
in role.h
#ifndef ROLES_H
#define ROLES_H
enum ROLE {
NA = 0x0,
TOWNFOLKS = 0x1,
WEREWOLVES = 0x2,
SEER = 0x3,
WITCH = 0x4,
THIEF = 0x5,
LITTLE_GIRL = 0x6,
HUNTER = 0x7,
CUPID = 0x8,
SHERIFF = 0x9
};
#endif // ROLES_H
in player.h
player(std::string name, std::string passwd, bool isAI)
: name(name), passwd(passwd), isAI(isAI) {}
- Code uploaded to github
- Learnt to work with mercurial SCM
- Learnt to work with Bitbucket instead of github
- Tried working with SDL -> Failed very fk*** hard -> stress 5 hours before deadline -> recode everything