예제 #1
0
 public ArticlePerItem(int id, String name, float price, PDV pdv)
 {
     this.id    = id;
     this.name  = name;
     this.price = price;
     this.pdv   = pdv;
 }
예제 #2
0
        public void defineNewArticle()
        {
            Console.WriteLine("Enter article name");
            string name = Console.ReadLine();

            if (name == null || name.Length == 0)
            {
                Console.WriteLine("Article name is mandatory");
            }

            Console.WriteLine("Enter article price");
            string price = Console.ReadLine();

            if (price == null || price.Length == 0)
            {
                Console.WriteLine("Article price is mandatory");
            }

            Console.WriteLine("Choose pdv type:");
            Console.WriteLine("1 - Croatian PDV");

            int pdvType = Int32.Parse(Console.ReadLine());
            PDV pdv     = null;

            if (pdvType == CroatianPDV.getInstance().getId())
            {
                pdv = CroatianPDV.getInstance();
            }
            else
            {
                Console.WriteLine("PDV type does not exists");
            }
            Console.WriteLine("Enter article type");
            Console.WriteLine("1 - Article per item");
            Console.WriteLine("2 - Article per kg");
            int articleType = Int32.Parse(Console.ReadLine());

            if (articleType == 1)
            {
                ArticlePerItem articlePerItem = new ArticlePerItem(Util.getGlobalIdCounter(), name, float.Parse(price), pdv);
                articlePerItem.save();
                Console.WriteLine("Article created:");
                articlePerItem.print();
            }
            else if (articleType == 2)
            {
                ArticlePerKg articlePerKg = new ArticlePerKg(Util.getGlobalIdCounter(), name, float.Parse(price), pdv);
                articlePerKg.save();
                Console.WriteLine("Article created:");
                articlePerKg.print();
            }
            else
            {
                Console.WriteLine("PDV type does not exists");
            }
        }