25 lines
430 B
C
25 lines
430 B
C
|
#ifndef square_h
|
||
|
#define square_h
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
#include "shape.h"
|
||
|
|
||
|
double squareArea(Shape* square) {
|
||
|
double side = square->perimeter / 4;
|
||
|
double area = side * side;
|
||
|
return area;
|
||
|
}
|
||
|
|
||
|
Shape* newSquare(double perimeter) {
|
||
|
Shape* square = malloc(sizeof(Shape));
|
||
|
square->numSides = 3;
|
||
|
square->perimeter = perimeter;
|
||
|
square->area = squareArea;
|
||
|
return square;
|
||
|
}
|
||
|
|
||
|
#endif
|
||
|
|
||
|
|
||
|
|