Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 23rd, 2012  |  syntax: C++  |  size: 1.46 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. */
  2. //Inkludering:
  3. #include <iostream>
  4. #include <fstream>
  5. #include "Bestillinger.h"
  6. #include "Bestilling.h"
  7. using namespace std;
  8.  
  9.  
  10. //Prosedyrer:
  11. Bestillinger::Bestillinger() { }
  12.  
  13. Bestillinger::Bestillinger(ifstream* inn) {
  14.         int temp_id;
  15.         Bestilling* temp_best;
  16.  
  17.         bestillinger = new List(Sorted);
  18.         *inn >> temp_id;
  19.         while (!inn->eof()) {
  20.                 temp_best = new Bestilling(temp_id, inn);
  21.                 //temp_best->Vis_Bestillingen();
  22.                 bestillinger->add(temp_best);
  23.                 *inn >> temp_id;
  24.         }
  25. }
  26.  
  27. void Bestillinger::Hent(int id) {
  28.         Bestilling* temp_best;
  29.  
  30.         temp_best = (Bestilling*) bestillinger->remove(id);
  31.         temp_best->Hent();
  32.         bestillinger->add(temp_best);
  33. }
  34.  
  35. bool Bestillinger::Finnes(int id) {
  36.         bool funnet;
  37.         Bestilling* temp;
  38.  
  39.         temp = (Bestilling*) bestillinger->remove(id);
  40.         if (temp) {
  41.                 funnet = true;
  42.                 bestillinger->add(temp);
  43.         }
  44.         else {
  45.                 funnet = false;
  46.         }
  47.  
  48.         return funnet;
  49. }
  50.  
  51. bool Bestillinger::Hentet(int id) {
  52.         bool hentet;
  53.         Bestilling* temp;
  54.  
  55.         temp = (Bestilling*) bestillinger->remove(id);
  56.         hentet = temp->Hentet();
  57.         bestillinger->add(temp);
  58.  
  59.         return hentet;
  60. }
  61.  
  62. void Bestillinger::Slett(int id) {
  63.         Bestilling* temp;
  64.  
  65.         temp = (Bestilling*) bestillinger->remove(id);
  66.         temp->Slett();
  67.         delete temp;
  68. }
  69.  
  70. int Bestillinger::Ny(int id, bool kjop) {
  71.         Bestilling* ny_best;
  72.         int ny_id = 2012000000;
  73.  
  74.         ny_id += (bestillinger->no_of_elements() + 1);
  75.         ny_best = new Bestilling(ny_id, id, kjop);
  76.         bestillinger->add(ny_best);
  77.         return ny_id;
  78. }