
Untitled
By: a guest on
Apr 23rd, 2012 | syntax:
C++ | size: 1.46 KB | hits: 16 | expires: Never
*/
//Inkludering:
#include <iostream>
#include <fstream>
#include "Bestillinger.h"
#include "Bestilling.h"
using namespace std;
//Prosedyrer:
Bestillinger::Bestillinger() { }
Bestillinger::Bestillinger(ifstream* inn) {
int temp_id;
Bestilling* temp_best;
bestillinger = new List(Sorted);
*inn >> temp_id;
while (!inn->eof()) {
temp_best = new Bestilling(temp_id, inn);
//temp_best->Vis_Bestillingen();
bestillinger->add(temp_best);
*inn >> temp_id;
}
}
void Bestillinger::Hent(int id) {
Bestilling* temp_best;
temp_best = (Bestilling*) bestillinger->remove(id);
temp_best->Hent();
bestillinger->add(temp_best);
}
bool Bestillinger::Finnes(int id) {
bool funnet;
Bestilling* temp;
temp = (Bestilling*) bestillinger->remove(id);
if (temp) {
funnet = true;
bestillinger->add(temp);
}
else {
funnet = false;
}
return funnet;
}
bool Bestillinger::Hentet(int id) {
bool hentet;
Bestilling* temp;
temp = (Bestilling*) bestillinger->remove(id);
hentet = temp->Hentet();
bestillinger->add(temp);
return hentet;
}
void Bestillinger::Slett(int id) {
Bestilling* temp;
temp = (Bestilling*) bestillinger->remove(id);
temp->Slett();
delete temp;
}
int Bestillinger::Ny(int id, bool kjop) {
Bestilling* ny_best;
int ny_id = 2012000000;
ny_id += (bestillinger->no_of_elements() + 1);
ny_best = new Bestilling(ny_id, id, kjop);
bestillinger->add(ny_best);
return ny_id;
}