Exemple #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);
 }
Exemple #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);
 }
 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);
 }
Exemple #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);
                }
            }
        }
        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);
        }
        public void AddMerchandise(Merchandise merchandise)
        {
            if (merchandise is Amulet)
            {
                {
                    Amulet amulet = (Amulet)merchandise;
                    merchandises.Add(Amulet) merchandise);
                }
            }
            else if (merchandise.add())


    }
Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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);
            }
        }
Exemple #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);
     }
 }
Exemple #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);
            }
        }
Exemple #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();
        }
Exemple #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();
        }
Exemple #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}");
         }
     }
 }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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;
        }
        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);
        }
Exemple #19
0
 public void AddToList(Amulet amulet)
 {
     Amulets.Add(amulet);
 }
 public Amulet GetAmulet(Amulet itemId)
 {
     return(itemId);
 }
 public void AddAmulet(Amulet amulet)
 {
     amulets.Add(amulet);
 }
Exemple #22
0
 public void AddAmulet(Amulet amulet)
 {
     amulets.Add(amulet);
     //Controller.Amulets = new List<Amulet> (amulets);
 }
 public void AddAmulet(Amulet amulet)
 {
 }