summaryrefslogtreecommitdiffstats
path: root/loans.h
blob: aed283ec2db043e90b80f46485178863c59de4f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include <stdlib.h>
#include <math.h>
#include "contract.h"

typedef enum loan_type {
	BULLET,
	STRAIGHTLINE,
	MORTGAGE,
} loan_type;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
typedef struct loan {
	loan_type type;
	contract *c;
} loan;
#pragma clang diagnostic pop

/**** BULLET LOAN ****/
contract *bullet_init(int n, int d, double r, double P);
double bullet_update(contract *);
void bullet_free(contract *c);

/**** STRAIGHT LINE ****/
contract *sl_init(int n, int d, double r, double P);
double sl_update(contract *);
void sl_free(contract *);

/**** MORTGAGE ****/
contract *mort_init(int n, int d, double r, double P);
double mort_update(contract *);
void mort_free(contract *);

/**** GENERAL LOAN STUFF ****/
loan loan_init(loan_type type, int n, int d, double r, double P);
double loan_update(loan);
void loan_free(loan);