Advertisement
AvengersAssemble

Q8 Q9

Nov 2nd, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1.         //Q8
  2.        
  3.         public static double TotalPrice(Node<Flower> flwrs)
  4.         {
  5.             double sum = 0;
  6.             while (flwrs != null)
  7.             {
  8.                 sum = sum + flwrs.GetInfo().Price;
  9.                 flwrs = flwrs.GetNext();
  10.             }
  11.  
  12.             return sum;
  13.         }
  14.  
  15.        //Q9
  16.         public static Flower HighestFlower(Node<Stack<Flower>> flwrs)
  17.         {
  18.             double max = 0;
  19.             Stack<Flower> temp;
  20.             double prc = 0;
  21.             Flower big = new Flower("temp", "temp", 0);
  22.             Flower tempflower;
  23.             while (flwrs != null)
  24.             {
  25.                 temp = flwrs.GetInfo();
  26.                 max = temp.Top().Price;
  27.                 while (temp.IsEmpty() == false)
  28.                 {
  29.                     tempflower = temp.Pop();
  30.                     prc = tempflower.Price;
  31.                     if (prc > max)
  32.                     {
  33.                         max = prc;
  34.                         big = tempflower;
  35.                        
  36.                     }
  37.                 }
  38.  
  39.                 flwrs = flwrs.GetNext();
  40.             }
  41.  
  42.             return big;
  43.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement