Skip to content

Instantly share code, notes, and snippets.

@erikroyall

erikroyall/oop.c Secret

Last active August 24, 2016 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikroyall/1447aa83e9b65a81f664521781423eed to your computer and use it in GitHub Desktop.
Save erikroyall/1447aa83e9b65a81f664521781423eed to your computer and use it in GitHub Desktop.
Objectification Oriented Programming
#include <stdio.h>
#include <stdlib.h>
#define YEP 1
#define NOPE 0
struct woman {
int makesSandwiches: 1, ironsClothes: 1, earnsMoney: 1;
};
struct man {
int cooks: 1, earnsMoney: 1, worksOut: 1;
};
_Bool isWomanNormal(struct woman dudette);
_Bool isManNormal(struct man *dude);
int main(void) {
struct woman pootina = {0, 0, 1};
struct man pooter = {0, 0, 1};
printf("Pootina is %s\n", (isWomanNormal(pootina) == 1) ? "normal" : "not normal");
printf("Pooter is %s\n", (isManNormal(&pooter) == 1) ? "normal" : "not normal");
return EXIT_SUCCESS;
}
_Bool isWomanNormal(struct woman dudette) {
if ((dudette.makesSandwiches == 0) || (dudette.ironsClothes == 0) || (dudette.earnsMoney == 1)) {
return NOPE;
}
return YEP;
}
_Bool isManNormal(struct man *dude) {
if ((dude->cooks == 1) || (dude->earnsMoney == 0) || (dude->worksOut == 0)) {
return NOPE;
}
return YEP;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment