Skip to content

Instantly share code, notes, and snippets.

@swillits
Created May 1, 2013 02:42
Show Gist options
  • Save swillits/5493431 to your computer and use it in GitHub Desktop.
Save swillits/5493431 to your computer and use it in GitHub Desktop.
//
// main.c
//
#include <stdio.h>
#include "Game.h"
int main(int argc, const char * argv[])
{
Game * game = NewGame();
RunGame(game);
return 0;
}
//
// Game.h
//
#ifndef Forward_Game_h
#define Forward_Game_h
typedef struct Game Game;
Game * NewGame();
void RunGame(Game * game);
#endif
//
// Game.c
//
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "Game.h"
#include "Manager.h"
struct Game {
int score;
Manager * manager;
};
Game * NewGame()
{
Game * game = (Game *)calloc(sizeof(Game), 1);
game->manager = NewManager();
return game;
}
void RunGame(Game * game)
{
UseManager(game->manager);
printf("Game over.\n");
}
//
// Manager.h
//
#ifndef Forward_Manager_h
#define Forward_Manager_h
typedef struct Manager Manager;
Manager * NewManager();
void UseManager(Manager * manager);
#endif
//
// Manager.c
//
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "Manager.h"
#include "Game.h"
struct Manager {
int stuff;
};
Manager * NewManager()
{
return (Manager *)calloc(sizeof(Manager), 1);
}
void UseManager(Manager * manager)
{
printf("Used manager.\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment