Ejemplo n.º 1
0
 public IValuable GetValuable(string ItemId) //TypeCasting
 {
     foreach (var valuable in valuables)
     {
         if (valuable is Book)
         {
             Book b = (Book)valuable;
             if (b.ItemId == ItemId)
             {
                 return(valuable);
             }
         }
         if (valuable is Amulet)
         {
             Amulet a = (Amulet)valuable;
             if (a.ItemId == ItemId)
             {
                 return(valuable);
             }
         }
         if (valuable is Course)
         {
             Course c = (Course)valuable;
             if (c.Name == ItemId)
             {
                 return(valuable);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
 public IValuable GetValuable(string id)
 {
     for (int i = 0; i < valuables.Count; i++)
     {
         if (valuables[i] is Amulet)
         {
             Amulet amulet = valuables[i] as Amulet;
             if (amulet.ItemId == id)
             {
                 return(amulet);
             }
         }
         else if (valuables[i] is Book)
         {
             Book book = valuables[i] as Book;
             if (book.ItemId == id)
             {
                 return(book);
             }
         }
         else if (valuables[i] is Course)
         {
             Course course = valuables[i] as Course;
             if (course.Name == id)
             {
                 return(course);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
 public IValuable GetValuable(string id)
 {
     foreach (IValuable oneValuable in valuables)
     {
         if (oneValuable is Book)
         {
             Book b = (Book)oneValuable;
             if (b.ItemId == id)
             {
                 return(oneValuable);
             }
         }
         if (oneValuable is Amulet)
         {
             Amulet a = (Amulet)oneValuable;
             if (a.ItemId == id)
             {
                 return(oneValuable);
             }
         }
         if (oneValuable is Course)
         {
             Course c = (Course)oneValuable;
             if (c.Name == id)
             {
                 return(oneValuable);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 4
0
        //public static double GetValueOfBook(Book book)
        //{
        //    return book.Price;
        //}

        public static double GetValueOfMerchandise(Merchandise merchandise)
        {
            if (merchandise is Amulet)
            {
                Amulet amulet = (Amulet)merchandise;
                Level  q      = amulet.Quality;
                // ændringhgchgc
                if (q == Level.low)
                {
                    return(12.5);
                }
                else if (q == Level.medium)
                {
                    return(20.0);
                }
                else
                {
                    return(27.5);
                }
            }
            else
            {
                if (merchandise is Book)
                {
                    Book book = (Book)merchandise;
                    return(book.Price);
                }
                else
                {
                    return(0);
                }
            }
        }
Ejemplo n.º 5
0
        public double GetValueOfMerchandise(Merchandise merchandise)
        {
            if (merchandise is Amulet)
            {
                Amulet amulet = (Amulet)merchandise;

                if (amulet.getQuality() == Amulet.Level.low)
                {
                    value = 12.5;
                }
                else if (amulet.getQuality() == Amulet.Level.medium)
                {
                    value = 20.0;
                }
                else
                {
                    value = 27.5;
                }
            }
            else if (merchandise is Book)
            {
                Book book = (Book)merchandise;
                value = book.Price;
            }
            else
            {
                value = 0;
            }
            return(value);
        }
Ejemplo n.º 6
0
        public void AddMerchandise(Merchandise merchandise)
        {
            if (merchandise is Amulet)
            {
                {
                    Amulet amulet = (Amulet)merchandise;
                    merchandises.Add(Amulet) merchandise);
                }
            }
            else if (merchandise.add())


    }
Ejemplo n.º 7
0
 public static double GetValueOfAmulet(Amulet amulet)
 {
     if (amulet.Quality.ToString() == "low")
     {
         return(12.5);
     }
     else if (amulet.Quality.ToString() == "medium")
     {
         return(20.0);
     }
     else
     {
         return(27.5);
     }
 }
Ejemplo n.º 8
0
 public static double GetValueOfAmulet(Amulet amulet)
 {
     if (amulet.Quality == Level.low)
     {
         return(12.5);
     }
     if (amulet.Quality == Level.medium)
     {
         return(20.0);
     }
     else
     {
         return(27.5);
     }
 }
Ejemplo n.º 9
0
        public static double GetValueOfAmulet(Amulet amulet)
        {
            switch (amulet.Quality)
            {
            case Level.low:
                return(LowQualityValue);

            case Level.medium:
                return(MediumQualityValue);

            case Level.high:
                return(HighQualityValue);

            default:
                return(0);
            }
        }
Ejemplo n.º 10
0
 public static double GetValueOfMerchendise(Merchendise merchendise)
 {
     if (merchendise is Book book)
     {
         Book b = (Book)merchendise;
         return(GetValueOfBook(book));
     }
     if (merchendise is Amulet amulet)
     {
         Amulet a = (Amulet)merchendise;
         return(GetValueOfAmulet(amulet));
     }
     else
     {
         return(0.0);
     }
 }
Ejemplo n.º 11
0
        public static double GetValueOfAmulet(Amulet amulet)
        {
            Level quality = amulet.Quality;

            if (quality == Level.low)
            {
                return(12.5);
                //return LowQualityValue;
            }
            else if (quality == Level.medium)
            {
                return(20.0);
            }
            else
            {
                return(27.5);
            }
        }
Ejemplo n.º 12
0
        public void Load(string filename)
        {
            StreamReader reader = new StreamReader(filename);
            string       line;
            Level        lvl = Level.low;

            while ((line = reader.ReadLine()) != null)
            {
                string[] split = line.Split(';');

                if (split[0] == "BOG")
                {
                    Book book = new Book(split[1].Substring(2), split[2], double.Parse(split[3]));
                    valuables.Add(book);
                }
                else if (split[0] == "AMULET")
                {
                    switch (split[2])
                    {
                    case "high":
                        lvl = Level.high;
                        break;

                    case "medium":
                        lvl = Level.medium;
                        break;

                    case "low":
                        lvl = Level.low;
                        break;
                    }
                    Amulet amulet = new Amulet(split[1].Substring(2), lvl, split[3]);
                    valuables.Add(amulet);
                }
                else if (split[0] == "KURSUS")
                {
                    Course cour = new Course(split[1], int.Parse(split[2]));
                    valuables.Add(cour);
                }
            }
            reader.Close();
        }
Ejemplo n.º 13
0
        public void Save()
        {
            StreamWriter writer;

            writer = new StreamWriter("ValuableRepository.txt");
            foreach (var valuable in valuables)
            {
                if (valuable is Book)
                {
                    Book b = (Book)valuable;
                    writer.WriteLine("Book;" + b.ItemId + ";" + b.Title + ";" + b.Price);
                }
                if (valuables is Amulet)
                {
                    Amulet a = (Amulet)valuable;
                    writer.WriteLine("Amulet;" + a.Quality + ";" + a.Design + ";" + a.Quality);
                }
            }
            writer.Close();
        }
Ejemplo n.º 14
0
 public void SaveMethod(TextWriter tw)
 {
     for (int i = 0; i < valuables.Count; i++)
     {
         if (valuables[i] is Amulet)
         {
             Amulet amulet = valuables[i] as Amulet;
             tw.WriteLine($"AMULET;{amulet.ItemId};{amulet.Quality};{amulet.Design}");
         }
         else if (valuables[i] is Book)
         {
             Book book = valuables[i] as Book;
             tw.WriteLine($"BOG;{book.ItemId};{book.Title};{book.Price}");
         }
         else if (valuables[i] is Course)
         {
             Course course = valuables[i] as Course;
             tw.WriteLine($"KURSUS;{course.Name};{course.DurationInMinutes};{course.CourseHourValue}");
         }
     }
 }
Ejemplo n.º 15
0
        public static double GetValueOfAmulet(Amulet amulet)
        {
            double price;

            switch (amulet.Quality)
            {
            case Level.low:
                price = 12.5;
                break;

            default:
            case Level.medium:
                price = 20d;
                break;

            case Level.high:
                price = 27.5;
                break;
            }

            return(price);
        }
Ejemplo n.º 16
0
        private static double GetValueOfAmulet(Amulet amulet)
        {
            double price;

            switch (amulet.Quality)
            {
            case Level.low:
                price = LowQualityValue;
                break;

            default:
            case Level.medium:
                price = MediumQualityValue;
                break;

            case Level.high:
                price = HighQualityValue;
                break;
            }

            return(price);
        }
Ejemplo n.º 17
0
        public static double GetValueOfAmulet(Amulet amulet)
        {
            double valueOfAmulet = 0;

            switch (amulet.Quality)
            {
                case (Level)0:
                    valueOfAmulet = 12.5;
                    break;
                case (Level)1:
                    valueOfAmulet = 20.0;
                    break;
                case (Level)2:
                    valueOfAmulet = 27.5;
                    break;
                default:
                    Console.WriteLine("Didn't work...");
                    break;
            }

            return valueOfAmulet;
        }
Ejemplo n.º 18
0
        public double GetTotalValue()
        {
            double totalValue = 0;

            foreach (IValuable oneValuable in valuables)
            {
                if (oneValuable is Book)
                {
                    Book oneBook = oneValuable as Book;
                    totalValue += oneBook.GetValue();
                }
                if (oneValuable is Amulet)
                {
                    Amulet oneAmulet = oneValuable as Amulet;
                    totalValue += oneAmulet.GetValue();
                }
                if (oneValuable is Course)
                {
                    Course oneCourse = oneValuable as Course;
                    totalValue += oneCourse.GetValue();
                }
            }
            return(totalValue);
        }
Ejemplo n.º 19
0
 public void AddToList(Amulet amulet)
 {
     Amulets.Add(amulet);
 }
Ejemplo n.º 20
0
 public Amulet GetAmulet(Amulet itemId)
 {
     return(itemId);
 }
Ejemplo n.º 21
0
 public void AddAmulet(Amulet amulet)
 {
     amulets.Add(amulet);
 }
Ejemplo n.º 22
0
 public void AddAmulet(Amulet amulet)
 {
     amulets.Add(amulet);
     //Controller.Amulets = new List<Amulet> (amulets);
 }
Ejemplo n.º 23
0
 public void AddAmulet(Amulet amulet)
 {
 }