#include "loans.h" #include "stdio.h" loan loan_init(loan_type type, int n, int d, double r, double P) { loan ret; ret.type = type; switch (type) { case BULLET: ret.c = bullet_init(n, d, r, P); break; case STRAIGHTLINE: ret.c = sl_init(n, d, r, P); break; case MORTGAGE: ret.c = mort_init(n, d, r, P); break; } return ret; } double loan_update(loan l) { switch (l.type) { case BULLET: return bullet_update(l.c); case STRAIGHTLINE: return sl_update(l.c); case MORTGAGE: return mort_update(l.c); } perror("Unkown Loan type supplied!"); exit(EXIT_FAILURE); } void loan_free(loan l) { switch (l.type) { case BULLET: bullet_free(l.c); break; case STRAIGHTLINE: sl_free(l.c); break; case MORTGAGE: mort_free(l.c); break; } }