first commit
This commit is contained in:
15
Lab3/atm.h
Normal file
15
Lab3/atm.h
Normal file
@@ -0,0 +1,15 @@
|
||||
//atm.h
|
||||
|
||||
#ifndef __ATM_H__
|
||||
|
||||
#define __ATM_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "cashcard.h"
|
||||
|
||||
class ATM {
|
||||
|
||||
public:
|
||||
|
||||
double withDraw(Cashcard &myCard, double money) {
|
||||
14
Lab3/bank.cpp
Normal file
14
Lab3/bank.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
//bank.cpp
|
||||
|
||||
#ifndef __BANK_CPP__
|
||||
|
||||
#define __BANK_CPP__
|
||||
|
||||
#include "person.h"
|
||||
|
||||
#include "bank.h"
|
||||
|
||||
Cashcard* Bank::makeCashcard(Passport &P) {
|
||||
|
||||
if(&P) {
|
||||
|
||||
16
Lab3/bank.h
Normal file
16
Lab3/bank.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//bank.h
|
||||
|
||||
#ifndef __BANK_H__
|
||||
|
||||
#define __BANK_H__
|
||||
|
||||
#include "passport.h"
|
||||
|
||||
#include "person.h"
|
||||
|
||||
class Bank {
|
||||
|
||||
public:
|
||||
|
||||
Bank(){}
|
||||
|
||||
19
Lab3/cashcard.h
Normal file
19
Lab3/cashcard.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//cashcard.h
|
||||
|
||||
#ifndef __CASHCARD_H__
|
||||
|
||||
#define __CASHCARD_H__
|
||||
|
||||
#include "name.h"
|
||||
|
||||
class ATM;
|
||||
|
||||
class Bank;
|
||||
|
||||
class Cashcard {
|
||||
|
||||
friend ATM;
|
||||
|
||||
friend Bank;
|
||||
|
||||
private:
|
||||
17
Lab3/main.cpp
Normal file
17
Lab3/main.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
//main.cpp
|
||||
|
||||
#include "person.h"
|
||||
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
Person myPerson(Name("Kalle !"), 20);
|
||||
|
||||
Police myStation;
|
||||
|
||||
Bank myBank;
|
||||
|
||||
ATM myATM;
|
||||
|
||||
if(myPerson.getPassport(myStation)) //Person gets a passport
|
||||
49
Lab3/name.cpp
Normal file
49
Lab3/name.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
//name.cpp
|
||||
|
||||
#ifndef __NAME_CPP__
|
||||
|
||||
#define __NAME_CPP__
|
||||
|
||||
#include <iostream.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "name.h"
|
||||
|
||||
//##################################################
|
||||
|
||||
// Name
|
||||
|
||||
// Puts name into a buffer
|
||||
|
||||
//==================================================
|
||||
|
||||
Name::Name(char *txt) {
|
||||
|
||||
buff = new char[strlen(txt) + 1];
|
||||
|
||||
strcpy(buff, txt);
|
||||
|
||||
}
|
||||
|
||||
//##################################################
|
||||
|
||||
// Destructor
|
||||
|
||||
// Delets buffer
|
||||
|
||||
//==================================================
|
||||
|
||||
Name::~Name() {
|
||||
|
||||
delete [] buff;
|
||||
|
||||
}
|
||||
|
||||
//##################################################
|
||||
|
||||
// Operator overload
|
||||
|
||||
// Deletes buffer and makes a new one
|
||||
14
Lab3/name.h
Normal file
14
Lab3/name.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//name.h
|
||||
|
||||
#ifndef __NAME_H__
|
||||
|
||||
#define __NAME_H__
|
||||
|
||||
class Name {
|
||||
|
||||
private:
|
||||
|
||||
char* buff;
|
||||
|
||||
public:
|
||||
|
||||
14
Lab3/passport.h
Normal file
14
Lab3/passport.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//passport.h
|
||||
|
||||
#ifndef __PASSPORT_H__
|
||||
|
||||
#define __PASSPORT_H__
|
||||
|
||||
#include "name.h"
|
||||
|
||||
class Passport {
|
||||
|
||||
private:
|
||||
|
||||
Name myName; //The name in the passport
|
||||
|
||||
54
Lab3/person.h
Normal file
54
Lab3/person.h
Normal file
@@ -0,0 +1,54 @@
|
||||
//person.h
|
||||
|
||||
#ifndef __PERSON_H__
|
||||
|
||||
#define __PERSON_H__
|
||||
|
||||
#include "police.h"
|
||||
|
||||
#include "atm.h"
|
||||
|
||||
|
||||
|
||||
#include "cashcard.h"
|
||||
|
||||
#include "bank.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
class Person {
|
||||
|
||||
private:
|
||||
|
||||
Name myName;
|
||||
|
||||
int myAge;
|
||||
|
||||
double cash;
|
||||
|
||||
Passport *myPass;
|
||||
|
||||
Cashcard *myCard;
|
||||
|
||||
public:
|
||||
|
||||
Person(Name &N, int &age):myName(N) { //Constructor
|
||||
|
||||
myPass=NULL;
|
||||
|
||||
myCard=NULL;
|
||||
|
||||
cash=0;
|
||||
|
||||
myAge=age;
|
||||
|
||||
}
|
||||
|
||||
~Person(){}
|
||||
|
||||
const Name &getName() { return myName; }
|
||||
|
||||
int getPassport(Police &myStation) {
|
||||
|
||||
11
Lab3/police.cpp
Normal file
11
Lab3/police.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
//police.cpp
|
||||
|
||||
#ifndef __POLICE_CPP__
|
||||
|
||||
#define __POLICE_CPP__
|
||||
|
||||
#include "person.h"
|
||||
|
||||
#include "police.h"
|
||||
|
||||
Passport* Police::makePassport(Person &P) {
|
||||
14
Lab3/police.h
Normal file
14
Lab3/police.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//police.h
|
||||
|
||||
#ifndef __POLICE_H__
|
||||
|
||||
#define __POLICE_H__
|
||||
|
||||
#include "passport.h"
|
||||
|
||||
#include "person.h"
|
||||
|
||||
class Person;
|
||||
|
||||
class Police {
|
||||
|
||||
13
Lab3/read_me
Normal file
13
Lab3/read_me
Normal file
@@ -0,0 +1,13 @@
|
||||
Avancerad programmering i C++
|
||||
|
||||
==========================================
|
||||
|
||||
|
||||
|
||||
Denna lab skapades med Borland C++ 5.0
|
||||
|
||||
Lägg alla .cpp i projektet.
|
||||
|
||||
Kompilera för EasyWin.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user