Greetings,
Heb volgende programma geschreven voor opdracht op school maar ben volgens mij iets stoms vergeten.
deBestelling.geefDoorWit() en deBestelling.geefDoorBruin() geven niet de juiste waardes weer.
Kan wel goed met C om maar mijn C++ is nog niet zo goed. Anyway, het programma :
===============
#include "Bestelling.h"
#include "Bon.h"
#include <iostream>
using namespace std;
void main() {
Bestelling bestelling1(5,1.00,4.50,5,0.90,4.00);
Bestelling bestelling2(10,1.05,7.50,4,1.10,3.40);
Bon bon1(bestelling1), bon2(bestelling2);
bestelling1.getAantal();
bon1.printBon();
cout << endl << "Druk op enter om te stoppen";
while (cin.get() != 'd')
cin.get();
}
===========================
//---------------------------------------------------------------------------
#ifndef BestellingH
#define BestellingH
//---------------------------------------------------------------------------
class Bestelling {
private:
int aantalWit;
int aantalBruin;
int aantalWitKorting;
int aantalBruinKorting;
double prijsBruin;
double prijsWit;
double prijs5Wit;
double prijs5Bruin;
public:
Bestelling(int aantalWitKorting, double prijsWit, double prijs5Wit, int aantalBruinKorting, double prijsBruin, double prijs5Bruin);
getAantal();
double bereken();
int geefDoorBruin();
int geefDoorWit();
};
#endif
=======================
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Bestelling.h"
#include <iostream.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
Bestelling::Bestelling(int aantalWitKorting, double prijsWit, double prijs5Wit, int aantalBruinKorting, double prijsBruin, double prijs5Bruin)
{
this -> aantalWitKorting = aantalWitKorting;
this -> prijsWit = prijsWit;
this -> prijs5Wit = prijs5Wit;
this -> aantalBruinKorting = aantalBruinKorting;
this -> prijsBruin = prijsBruin;
this -> prijs5Bruin = prijs5Bruin;
}
Bestelling::getAantal()
{
cout << "Hoeveel Witte broodjes wilt U ?";
cin >> aantalWit;
cout << endl << "Hoeveel Bruine broodjes wilt U ?";
cin >> aantalBruin;
}
double Bestelling::bereken()
{ int tempWit, tempBruin, restWit, restBruin;
double totaalWit, totaalBruin;
tempWit = aantalWit%aantalWitKorting;
restWit = aantalWit-tempWit;
totaalWit = tempWit*prijsWit + restWit/5*prijs5Wit;
tempBruin = aantalBruin%aantalBruinKorting;
restBruin = aantalBruin-tempBruin;
totaalBruin = tempBruin*prijsBruin + restBruin/5*prijs5Bruin;
return (totaalWit+totaalBruin);
}
int Bestelling::geefDoorWit()
{
cout << "Beta " << aantalWit;
return aantalWit;
}
int Bestelling::geefDoorBruin()
{
return aantalBruin;
}
========================
#include "Bestelling.h"
//---------------------------------------------------------------------------
#ifndef BonH
#define BonH
//---------------------------------------------------------------------------
class Bon {
private:
Bestelling deBestelling;
public:
Bon(Bestelling deBestelling);
printBon();
};
#endif
================================
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Bon.h"
#include <iostream.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
Bon::Bon(Bestelling deBestelling):deBestelling(deBestelling)
{}
Bon::printBon()
{
cout << "Aantal Wit: " << deBestelling.geefDoorWit() << endl;
cout << "Aantal Bruin: " << deBestelling.geefDoorBruin() << endl;
cout << "Totaal : " << deBestelling.bereken() << endl;
}
==============================
Weet zeker dat het iets dom is. Wie kan mij helpen ? (PLEEEASE)
Heb volgende programma geschreven voor opdracht op school maar ben volgens mij iets stoms vergeten.
deBestelling.geefDoorWit() en deBestelling.geefDoorBruin() geven niet de juiste waardes weer.
Kan wel goed met C om maar mijn C++ is nog niet zo goed. Anyway, het programma :
===============
#include "Bestelling.h"
#include "Bon.h"
#include <iostream>
using namespace std;
void main() {
Bestelling bestelling1(5,1.00,4.50,5,0.90,4.00);
Bestelling bestelling2(10,1.05,7.50,4,1.10,3.40);
Bon bon1(bestelling1), bon2(bestelling2);
bestelling1.getAantal();
bon1.printBon();
cout << endl << "Druk op enter om te stoppen";
while (cin.get() != 'd')
cin.get();
}
===========================
//---------------------------------------------------------------------------
#ifndef BestellingH
#define BestellingH
//---------------------------------------------------------------------------
class Bestelling {
private:
int aantalWit;
int aantalBruin;
int aantalWitKorting;
int aantalBruinKorting;
double prijsBruin;
double prijsWit;
double prijs5Wit;
double prijs5Bruin;
public:
Bestelling(int aantalWitKorting, double prijsWit, double prijs5Wit, int aantalBruinKorting, double prijsBruin, double prijs5Bruin);
getAantal();
double bereken();
int geefDoorBruin();
int geefDoorWit();
};
#endif
=======================
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Bestelling.h"
#include <iostream.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
Bestelling::Bestelling(int aantalWitKorting, double prijsWit, double prijs5Wit, int aantalBruinKorting, double prijsBruin, double prijs5Bruin)
{
this -> aantalWitKorting = aantalWitKorting;
this -> prijsWit = prijsWit;
this -> prijs5Wit = prijs5Wit;
this -> aantalBruinKorting = aantalBruinKorting;
this -> prijsBruin = prijsBruin;
this -> prijs5Bruin = prijs5Bruin;
}
Bestelling::getAantal()
{
cout << "Hoeveel Witte broodjes wilt U ?";
cin >> aantalWit;
cout << endl << "Hoeveel Bruine broodjes wilt U ?";
cin >> aantalBruin;
}
double Bestelling::bereken()
{ int tempWit, tempBruin, restWit, restBruin;
double totaalWit, totaalBruin;
tempWit = aantalWit%aantalWitKorting;
restWit = aantalWit-tempWit;
totaalWit = tempWit*prijsWit + restWit/5*prijs5Wit;
tempBruin = aantalBruin%aantalBruinKorting;
restBruin = aantalBruin-tempBruin;
totaalBruin = tempBruin*prijsBruin + restBruin/5*prijs5Bruin;
return (totaalWit+totaalBruin);
}
int Bestelling::geefDoorWit()
{
cout << "Beta " << aantalWit;
return aantalWit;
}
int Bestelling::geefDoorBruin()
{
return aantalBruin;
}
========================
#include "Bestelling.h"
//---------------------------------------------------------------------------
#ifndef BonH
#define BonH
//---------------------------------------------------------------------------
class Bon {
private:
Bestelling deBestelling;
public:
Bon(Bestelling deBestelling);
printBon();
};
#endif
================================
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Bon.h"
#include <iostream.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
Bon::Bon(Bestelling deBestelling):deBestelling(deBestelling)
{}
Bon::printBon()
{
cout << "Aantal Wit: " << deBestelling.geefDoorWit() << endl;
cout << "Aantal Bruin: " << deBestelling.geefDoorBruin() << endl;
cout << "Totaal : " << deBestelling.bereken() << endl;
}
==============================
Weet zeker dat het iets dom is. Wie kan mij helpen ? (PLEEEASE)