Last active
December 13, 2015 20:58
-
-
Save vermiculus/4973618 to your computer and use it in GitHub Desktop.
Marissa's Classes -- a transcription a Facebook chat with an extraordinarily clever girl who deserves a higher level of self-esteem and confidence.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include "Line.h" | |
int getLength (Line *l) { | |
return l->p2->x - l->p1->x; | |
} | |
Line* NewLine(void) { | |
Line *l = (Line*) malloc (sizeof (Line)); | |
l->p1 = NewPoint(); | |
l->p2 = NewPoint(); | |
l->p1->x = 0; | |
l->p2->x = 0; | |
return l; | |
} | |
void KillLine(Line *l) { | |
KillPoint(l->p1); | |
KillPoint(l->p2); | |
free(l); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Point.h" | |
typedef struct { | |
Point *p1, *p2; | |
} Line; | |
int getLength (Line *l); | |
Line* NewLine(void); | |
void KillLine(Line *l); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include "Line.h" // Line.h already includes Point | |
int main(int argc, const char * argv[]) { | |
printf("Hi. \n"); | |
Line *l = NewLine(); | |
l->p1->x = -1; | |
l->p2->x = 1; | |
printf("Length: %d\n", getLength(l)); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Point.h" | |
#include <stdlib.h> | |
int getDistance(Point *p) { | |
return p->x; | |
} | |
Point * NewPoint(void) { | |
Point *p = (Point *) malloc (sizeof (Point)); | |
p->x = 0; | |
return p; | |
} | |
void KillPoint(Point *p) { | |
free(p); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Marissa wrote all of this. | |
// Copied and pasted right from Facebook chat. | |
typedef struct { | |
int x; | |
} Point; | |
int getDistance(Point *p); | |
Point* NewPoint(void); | |
void KillPoint(Point *p); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment