static void Main(string[] args) { List <Product> listProduct = new List <Product>(); Console.Write("Enter the number of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or imported (c/u/i)? "); char ch = char.Parse(Console.ReadLine()); if (ch == 'c') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product product = new Product(name, price); listProduct.Add(product); } else if (ch == 'u') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Manufacture date(DD/ MM / YYYY): "); DateTime manufactureDate = DateTime.Parse(Console.ReadLine()); Product product = new UsedProduct(name, price, manufactureDate); listProduct.Add(product); } else if (ch == 'i') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Customs fee: "); double customFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product product = new ImportedProduct(name, price, customFee); listProduct.Add(product); } } Console.WriteLine("PRICE TAGS"); foreach (Product product in listProduct) { Console.WriteLine(product.PriceTag()); } }
static void Main(string[] args) { Console.WriteLine("PRODUCT PROGRAM!\n"); Console.Write("Deseja Cadastrar um produto?(S/N): "); char response = char.Parse(Console.ReadLine()); Product prod = new Product(); List <Product> listProducts = new List <Product>(); if (response == 's' || response == 'S') { do { Console.Write("O produto será do tipo: 1 Normal - 2 Importado - 3 Usado: "); int typeProduc = int.Parse(Console.ReadLine()); Console.Write("Entre com o nome do produto: "); string name = Console.ReadLine(); Console.Write("Entre com o preço do produto: "); double price = double.Parse(Console.ReadLine()); //Instanciando os objetos de acordo com o tipo de produto escolhido. switch (typeProduc) { case 1: prod = new Product(name, price); break; case 2: Console.Write("Entre com o valor de alfândega: "); double customesFree = double.Parse(Console.ReadLine()); prod = new ImportedProduct(name, price, customesFree); break; case 3: Console.Write("Entre com a data de fabricação: "); DateTime manufactureDate = DateTime.Parse(Console.ReadLine()); prod = new UsedProduct(name, price, manufactureDate); break; default: Console.WriteLine("Opção inválida, programa encerrado!"); break; } listProducts.Add(prod); Console.Write("\nDeseja Cadastrar um outro produto? (S/N): "); response = char.Parse(Console.ReadLine()); } while (response == 's' || response == 'S'); Console.WriteLine("PRODUTOS:\n"); foreach (Product item in listProducts) { Console.WriteLine(item.PriceTag()); } } }
static void Main(string[] args) { List <Product> list = new List <Product>(); Console.Write("Enter the number of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data: "); Console.Write("Common, Used or Imported (C / U / I)? "); char type = char.Parse(Console.ReadLine().ToUpper()); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); double customFee = 0.0; DateTime manufactureDate = DateTime.Now; if (type == 'I') { Console.Write("Customs fee: "); customFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); } if (type == 'U') { Console.Write("Manufacture date (DD/MM/YYYY): "); manufactureDate = DateTime.Parse(Console.ReadLine()); } Product product; if (type == 'C') { product = new Product(name, price); list.Add(product); } else if (type == 'U') { product = new UsedProduct(name, price, manufactureDate); list.Add(product); } else if (type == 'I') { product = new ImportedProduct(name, price, customFee); list.Add(product); } } Console.WriteLine(); Console.WriteLine("PRICE TAGS:"); foreach (Product product in list) { Console.WriteLine(product.PriceTag()); } }
static void Main(string[] args) { List <Product> list = new List <Product>(); Console.Write("Enter the number of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data: "); Console.Write("Common, used or imported (c/u/i)? "); char ch = char.Parse(Console.ReadLine()); if (ch == 'i') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Customs fee: "); double customsFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); ImportedProduct imp = new ImportedProduct(name, price, customsFee); list.Add(imp); } else if (ch == 'c') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product comum = new Product(name, price); list.Add(comum); } else if (ch == 'u') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime dateProd = DateTime.Parse(Console.ReadLine()); UsedProduct used = new UsedProduct(name, price, dateProd); list.Add(used); } else if (ch != 'i' || ch != 'u' || ch != 'c') { Console.WriteLine("Opção Inválida. Por favor, tente novamente!"); i--; } } Console.WriteLine("PRICE TAGS: "); foreach (Product prod in list) { Console.WriteLine(prod.priceTag(), CultureInfo.InvariantCulture); Console.ReadKey(); } }
static void Main(string[] args) { List <Product> list = new List <Product>(); Console.Write("Enter the number of the products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or imported (c/u/i)? "); char c = char.Parse(Console.ReadLine()); switch (c) { case 'c': Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product product = new Product(name, price); list.Add(product); break; case 'u': Console.Write("Name: "); name = Console.ReadLine(); Console.Write("Price: "); price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime date = DateTime.Parse(Console.ReadLine()); product = new UsedProduct(name, price, date); list.Add(product); break; case 'i': Console.Write("Name: "); name = Console.ReadLine(); Console.Write("Price: "); price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Customs fee: "); double customsFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); product = new ImportedProduct(name, price, customsFee); list.Add(product); break; default: break; } } Console.WriteLine(); Console.WriteLine("PRICE TAGS:"); foreach (Product obj in list) { Console.WriteLine(obj.PriceTag()); } }
static void Main(string[] args) { List <Product> products = new List <Product>(); Console.Write("Enter the number of products: "); int count = int.Parse(Console.ReadLine()); for (int i = 1; i <= count; i++) { Console.WriteLine(); Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or import (c/u/i)? "); char type = char.Parse(Console.ReadLine()); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); if (type == 'i') { Console.Write("Custom fee: "); double customFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product prod = new ImportedProduct(name, price, customFee); products.Add(prod); } else if (type == 'u') { Console.Write("Manufacture date: "); DateTime date = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy", CultureInfo.InvariantCulture); Product prod = new UsedProduct(name, price, date); products.Add(prod); } else if (type == 'c') { Product prod = new Product(name, price); products.Add(prod); } else { Console.WriteLine("[ERROR]: unknown product type"); } } Console.WriteLine(); Console.WriteLine("PRICE TAGS: "); foreach (var product in products) { Console.WriteLine(product.PriceTag()); } }
static void Main(string[] args) { Product p1 = new Product("Iphone XI", 5000); Product p2 = new ImportedProduct("Iphone XI", 4000, 20); Product p3 = new UsedProduct("Iphone 6", 800, new DateTime(2016, 06, 01)); Console.WriteLine(p1.PriceTag()); Console.WriteLine(p2.PriceTag()); Console.WriteLine(p3.PriceTag()); }
static void Main(string[] args) { Product product = new Product("Noteebok", 1100.00); Product productUsed = new UsedProduct(DateTime.Today, "Iphone", 1100.00); Product productImported = new ImportedProduct("Tablet", 1100.00, 20.00); Console.WriteLine(productImported.PriceTag()); Console.WriteLine(product.PriceTag()); Console.WriteLine(productUsed.PriceTag()); }
static void Main(string[] args) { List <Product> list = new List <Product>(); Console.Write("Enter the numer of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or imported(c/u/i): "); char aux = char.Parse(Console.ReadLine()); if (aux == 'c' || aux == 'C') { Console.Write("Name: "); string Name = Console.ReadLine(); Console.Write("Price: "); double Price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product Product = new Product(Name, Price); list.Add(Product); } else if (aux == 'u' || aux == 'U') { Console.Write("Name: "); string Name = Console.ReadLine(); Console.Write("Price: "); double Price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Manufacture date(DD/MM/YYYY): "); DateTime date = DateTime.Parse(Console.ReadLine()); UsedProduct usedProduct = new UsedProduct(Name, Price, date); list.Add(usedProduct); } else { Console.Write("Name: "); string Name = Console.ReadLine(); Console.Write("Price: "); double Price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Customs fee: "); double CustomsFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); ImportedProduct Imported = new ImportedProduct(Name, Price, CustomsFee); list.Add(Imported); } } Console.WriteLine(); Console.WriteLine("Price tags:"); foreach (Product prod in list) { Console.WriteLine(prod.PriceTag()); } }
static void Main(string[] args) { List <Product> productsList = new List <Product>(); Console.Write("Enter the number of products: "); int controlExec = int.Parse(Console.ReadLine()); for (int i = 1; i <= controlExec; i++) { Console.WriteLine("Product {0} data: ", i); Console.Write("Common, used or imported (c/u/i)? "); char validValue = char.Parse(Console.ReadLine()); Console.Write("Name: "); string nameProduct = Console.ReadLine(); Console.Write("Price: "); double priceProduct = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); if (validValue == 'i') { Console.Write("Customs fee: "); double customs = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); ImportedProduct newImported = new ImportedProduct(nameProduct, priceProduct, customs); productsList.Add(newImported); } else if (validValue == 'u') { Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime manufactureDate = DateTime.Parse(Console.ReadLine()); UsedProduct newUsed = new UsedProduct(nameProduct, priceProduct, manufactureDate); productsList.Add(newUsed); } else if (validValue == 'c') { Product newCommon = new Product(nameProduct, priceProduct); productsList.Add(newCommon); } Console.WriteLine(); Console.WriteLine(); } Console.WriteLine("PRICE TAGS:"); Console.WriteLine(); foreach (Product obj in productsList) { Console.WriteLine(obj.PriceTag().ToString()); Console.WriteLine(); } }
static void Main(string[] args) { List <Product> list = new List <Product>(); Console.Write("Enter the number of products:"); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.Write("Common, used or imported (c/u/i)?"); char c = char.Parse(Console.ReadLine()); Console.WriteLine("Product #" + i + " data:"); if (c == 'c') { Console.Write("Name:"); string name = Console.ReadLine(); Console.Write("Price:"); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product prod = new Product(name, price); list.Add(prod); } else if (c == 'u') { Console.Write("Name:"); string name = Console.ReadLine(); Console.Write("Price:"); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Manufecture date:"); DateTime date = DateTime.Parse(Console.ReadLine()); UsedProduct used = new UsedProduct(name, price, date); list.Add(used); } else if (c == 'i') { Console.Write("Name:"); string name = Console.ReadLine(); Console.Write("Price:"); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Console.Write("Customs fee:"); double fee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); ImportedProduct import = new ImportedProduct(name, price, fee); list.Add(import); } } Console.WriteLine(""); Console.WriteLine("PRICE TAGS"); foreach (Product prod in list) { Console.WriteLine(prod.priceTag()); } }
static void Main(string[] args) { Console.Write("Enter the number of products: "); int op = int.Parse(Console.ReadLine()); List <Product> produtos = new List <Product>(); for (int i = 1; i <= op; i++) { Console.WriteLine($"Product #{i} data: "); Console.Write("Common, used or imported (c/u/i)? "); char opc = char.Parse(Console.ReadLine()); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); if (opc == 'i' || opc == 'I') { Console.Write("Customs fee: "); double cf = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product p = new ImportedProduct(cf, name, price); produtos.Add(p); } else if (opc == 'u' || opc == 'U') { Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime md = DateTime.Parse(Console.ReadLine()); Product p = new UsedProduct(md, name, price); produtos.Add(p); } else if (opc == 'c' || opc == 'C') { Product p = new Product(name, price); produtos.Add(p); } else { Console.WriteLine("Opção inválida. "); } } Console.WriteLine("PRICE TAGS: "); foreach (Product product in produtos) { Console.WriteLine(product.PriceTag()); } }
static void Main(string[] args) { List <Product> productList = new List <Product>(); Console.Write("Enter the number of products: "); int number = int.Parse(Console.ReadLine()); for (int i = 1; i <= number; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or imported (c/u/i)? "); char type = char.Parse(Console.ReadLine()); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); switch (type) { case 'i': Console.Write("Custom free: "); double cf = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product productI = new ImportedProduct(name, price, cf); productList.Add(productI); break; case 'u': Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime date = DateTime.Parse(Console.ReadLine()); Product productU = new UsedProduct(name, price, date); productList.Add(productU); break; default: Product product = new Product(name, price); productList.Add(product); break; } } Console.WriteLine(); foreach (Product p in productList) { Console.WriteLine("PRICE TAGS"); Console.WriteLine(p.PriceTag()); } Console.WriteLine("Teste"); string teste = Console.ReadLine(); }
static void Main(string[] args) { List <Product> products = new List <Product>(); Console.Write("Enter the number of products: "); int numberProducts = int.Parse(Console.ReadLine()); for (int i = 1; i <= numberProducts; i++) { Console.WriteLine("Product #" + i + " data"); Console.Write("Common, used or imported (c/u/i)"); char typeProduct = char.Parse(Console.ReadLine()); if (typeProduct == 'i') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine()); Console.Write("Custom fee: "); double customFee = double.Parse(Console.ReadLine()); Product product = new ImportedProduct(name, price, customFee); products.Add(product); } else if (typeProduct == 'c') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine()); Product product = new Product(name, price); products.Add(product); } else if (typeProduct == 'u') { Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine()); Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime manufactureDate = DateTime.Parse(Console.ReadLine()); Product product = new UsedProduct(name, price, manufactureDate); products.Add(product); } } Console.WriteLine("PRICE TAGS:"); foreach (Product p in products) { Console.WriteLine(p.PriceTag()); } }
public ActionResult Create([Bind(Include = "Id,ProductId,Date,AmountImported,Comments")] ImportedProduct importedProduct) { if (ModelState.IsValid) { importedProduct.Id = Guid.NewGuid(); context.ImportedProducts.Add(importedProduct); context.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductId = new SelectList(context.Products.OrderBy(p => p.Code), "Id", "Title", importedProduct.ProductId); return(View(importedProduct)); }
static void Main(string[] args) { List <Product> Products = new List <Product>(); Console.Write("Enter the number of the products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or imported (c/u/i)? "); string choose = Console.ReadLine(); while (choose != "c" && choose != "u" && choose != "i") { Console.Write("You need to choose if the product is common(c), used(u) or imported(i). Choose again: "); choose = Console.ReadLine(); } Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); if (choose == "c") { Product product = new Product(name, price); Products.Add(product); } else if (choose == "i") { Console.Write("Customs Fee: "); double customsFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product product = new ImportedProduct(name, price, customsFee); Products.Add(product); } else { Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime manufactureDate = DateTime.Parse(Console.ReadLine()); Product product = new UsedProduct(name, price, manufactureDate); Products.Add(product); } } Console.WriteLine(); Console.WriteLine("PRICE TAGS:"); foreach (Product product in Products) { Console.WriteLine(product.PriceTag()); } }
static void Main(string[] args) { List <Product> list = new List <Product>(); Console.Write("Enter the number of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { string tipo; Console.WriteLine("Product #" + i + " data:"); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine()); Product p = new Product(); Console.WriteLine("Common, used or imported (c/u/i)? "); tipo = Console.ReadLine().ToUpper(); p.Name = name; p.Price = price; if (tipo == "C") { list.Add(p); } else if (tipo == "I") { Console.Write("Customs fee: "); double customsFee = double.Parse(Console.ReadLine()); ImportedProduct ip = new ImportedProduct(); ip.CustomsFee = customsFee; ip.Name = name; ip.Price = price; list.Add(ip); } else if (tipo == "U") { Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime manufacturedDate = DateTime.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); UsedProduct up = new UsedProduct(); up.ManufacturedDate = manufacturedDate; up.Name = name; up.Price = price; list.Add(up); } } Console.WriteLine("PRICE TAGS:"); foreach (Product p in list) { Console.WriteLine(p.PriceTag()); } }
static void Main(string[] args) { Console.WriteLine("Enter with de number of products"); int n1 = int.Parse(Console.ReadLine()); List <Product> p1 = new List <Product>(); for (int i = 0; i < n1; i++) { if (i > 0) { Console.WriteLine("--------------------------------"); } Console.Write("This product is:\nCommon(C), Used(U) or Imported(I)"); string type = Console.ReadLine().ToUpper(); Console.WriteLine("Product #{0}: ", i + 1); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine()); switch (type) { case "C": Product c1 = new Product(name, price); p1.Add(c1); break; case "U": Console.Write("Manufacture Date: (DD/MM/YYY): "); DateTime manucafture = DateTime.Parse(Console.ReadLine()); Product u1 = new UsedProduct(manucafture, name, price); p1.Add(u1); break; case "I": Console.WriteLine("Customs fee: "); double fee = double.Parse(Console.ReadLine()); Product i1 = new ImportedProduct(fee, name, price); p1.Add(i1); break; default: Console.WriteLine("Invalid"); break; } } foreach (Product product in p1) { Console.WriteLine(product.PriceTag()); } }
public ActionResult DeleteConfirmed(Guid id) { ImportedProduct importedProduct = context.ImportedProducts.Include(i => i.AllocatedProducts).Where(p => p.Id == id).FirstOrDefault(); if (importedProduct.AllocatedProducts.Count > 0) { ModelState.AddModelError("AmountImported", "مقدار تخصیص داده شده دارد"); return(RedirectToAction("Delete")); } context.ImportedProducts.Remove(importedProduct); context.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Storage/ImportedProducts/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ImportedProduct importedProduct = context.ImportedProducts.Find(id); if (importedProduct == null) { return(HttpNotFound()); } return(View(importedProduct)); }
static void Main(string[] args) { List <Product> prod = new List <Product>(); Console.Write("Enter the number of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or imported (c/u/i)? "); char c = char.Parse(Console.ReadLine()); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine()); if (c == 'u') { Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime date = DateTime.Parse(Console.ReadLine()); UsedProduct pU = new UsedProduct(name, price, date); prod.Add(pU); } if (c == 'i') { Console.Write("Customs fee: "); double fee = double.Parse(Console.ReadLine()); ImportedProduct pI = new ImportedProduct(name, price, fee); prod.Add(pI); } if (c == 'c') { Product pC = new Product(name, price); prod.Add(pC); } } Console.WriteLine(); Console.WriteLine("PRICE TAGS:"); foreach (Product p in prod) { Console.WriteLine(p.PriceTag()); } }
static void Main(string[] args) { List <Product> products = new List <Product>(); Console.Write("Enter the number of products: "); int numberOfProducts = int.Parse(Console.ReadLine()); for (int i = 0; numberOfProducts > i; i++) { Console.Write("\nCommon product[C] - Used product[U] - Imported product[I]: "); char commonOrUsedOrImported = char.Parse(Console.ReadLine().Substring(0, 1).ToUpper()); Console.Write("\nName: "); string name = Console.ReadLine(); Console.Write("\nPrice: "); double price = double.Parse(Console.ReadLine()); if (commonOrUsedOrImported.Equals('C')) { Product common = new Product(name, price); products.Add(common); } else if (commonOrUsedOrImported.Equals('I')) { Console.Write("\nCustoms fee: "); double customsFee = double.Parse(Console.ReadLine()); Product imported = new ImportedProduct(name, price, customsFee); products.Add(imported); } else if (commonOrUsedOrImported.Equals('U')) { Console.Write("\nManufacture date(DD/MM/YYYY): "); DateTime manufactureDate = DateTime.Parse(Console.ReadLine()); Product used = new UsedProduct(name, price, manufactureDate); products.Add(used); } Console.WriteLine("\n================================="); } Console.WriteLine("\n=================================\n"); foreach (Product product in products) { Console.WriteLine($"Category: {(product.GetType().Name).Insert(product.GetType().Name.IndexOf("Product"), " ")}\n{product.PriceTag()}"); Console.WriteLine("\n=================================\n"); } }
public void RegisterProd() { Console.WriteLine("Enter the number of products: "); int qtd = int.Parse(Console.ReadLine()); List <Product> products = new List <Product>(); for (int i = 1; i <= qtd; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or imported (c/u/i)? "); char escolha = char.Parse(Console.ReadLine()); Console.Write("Name : "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine()); switch (escolha) { case 'i': Console.Write("Customs fee: "); double customsFee = double.Parse(Console.ReadLine()); ImportedProduct imported = new ImportedProduct(name, price, customsFee); products.Add(imported); break; case 'c': Product product = new Product(name, price); products.Add(product); break; case 'u': Console.Write("Manufacture date (YYYY/MM/DD): "); DateTime date = DateTime.Parse(Console.ReadLine()); UsedProduct usedProduct = new UsedProduct(name, price, date); products.Add(usedProduct); break; default: Console.WriteLine("Insira o valor correto!"); break; } } Console.WriteLine("PRICE TAGS: "); foreach (Product product in products) { Console.WriteLine(product.PriceTag()); } }
static void Main(string[] args) { Product pro = new ImportedProduct("Monitor", 1000.00, 150.00); Product pro2 = new UsedProduct("Mouse", 100.00, DateTime.Parse("2019-10-10")); System.Console.WriteLine(pro.PriceTag()); System.Console.WriteLine(pro2.PriceTag()); //ImportedProduct impo = (ImportedProduct) pro; //Duas formas de fazer um downcasting ImportedProduct impo = pro as ImportedProduct; //Outra forma de fazer o downcasting System.Console.WriteLine(impo.TotalPrice()); }
// GET: Storage/ImportedProducts/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ImportedProduct importedProduct = context.ImportedProducts.Find(id); if (importedProduct == null) { return(HttpNotFound()); } ViewBag.ProductId = new SelectList(context.Products.OrderBy(p => p.Code), "Id", "Title", importedProduct.ProductId); return(View(importedProduct)); }
public double CalculateAmountToAlloc(double amountWishToAlloc, ImportedProduct importedProduct) { if (amountWishToAlloc > importedProduct.AmountUnAllocated) { return(importedProduct.AmountUnAllocated); } else if (amountWishToAlloc < importedProduct.AmountUnAllocated) { return(amountWishToAlloc); } else { return(amountWishToAlloc); } }
static void Main(string[] args) { List <Product> list = new List <Product>(); Console.Write("Enter the number of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data: "); Console.Write("Common, used or imported (c/u/i)? "); string import = Console.ReadLine(); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); if (import == "i") { Console.Write("Custom fee: "); double fee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); list.Add(new ImportedProduct(name, price, fee)); Product Import = new ImportedProduct(); Import.PriceTag(import); } else if (import == "u") { Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime manufacture = DateTime.Parse(Console.ReadLine()); list.Add(new UsedProduct(name, price, manufacture)); Product used = new UsedProduct(); used.PriceTag(import); } else { list.Add(new Product(name, price)); Product product = new Product(); product.PriceTag(import); } } Console.WriteLine(); foreach (Product product in list) { Console.WriteLine(product); } Console.WriteLine(); }
static void Main(string[] args) { List <Product> products = new List <Product>(); Console.Write("Enter the number of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data: "); Console.Write("Common, used or imported (c/u/i)?"); string type = Console.ReadLine(); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); if (type == "i") { Console.Write("Customs fee: "); double customsFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); Product imp = new ImportedProduct(name, price, customsFee); products.Add(imp); } else if (type == "u") { Console.Write("Manufacture date (DD/MM/YYYY): "); DateTime manufDate = DateTime.Parse(Console.ReadLine()); Product used = new UsedProduct(name, price, manufDate); products.Add(used); } else { products.Add(new Product(name, price)); } } Console.WriteLine(); Console.WriteLine("PRICE TAGS:"); foreach (Product item in products) { Console.WriteLine(item.PriceTag()); } }
static void Main(string[] args) { Console.Write("Enter the number of product: "); int n = int.Parse(Console.ReadLine()); List <Product> products = new List <Product>(); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Commom, used or imported (c/u/i)? "); char type = char.Parse(Console.ReadLine()); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); switch (type) { case 'c': Product p = new Product(name, price); products.Add(p); break; case 'i': Console.Write("Customs fee: "); double customsFee = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture); p = new ImportedProduct(name, price, customsFee); products.Add(p); break; case 'u': Console.Write("Manufacture date (DD/MM/YYYY)"); DateTime manufactureDate = DateTime.Parse(Console.ReadLine()); p = new UsedProduct(name, price, manufactureDate); products.Add(p); break; default: Console.WriteLine("Tipo inválido."); i--; break; } } foreach (Product product in products) { Console.WriteLine(product.PriceTag()); } }
static void Main(string[] args) { List <Product> list = new List <Product>(); Console.Write("Enter the number of products: "); int n = int.Parse(Console.ReadLine()); for (int i = 1; i <= n; i++) { Console.WriteLine($"Product #{i} data:"); Console.Write("Common, used or imported (c/u/i) ?: "); char type = char.Parse(Console.ReadLine()); Console.Write("Name: "); string name = Console.ReadLine(); Console.Write("Price: "); double price = double.Parse(Console.ReadLine()); if (type == 'u') { Console.Write("Manuacture Date: "); DateTime manufactureDate = DateTime.Parse(Console.ReadLine()); UsedProduct used = new UsedProduct(name, price, manufactureDate); list.Add(used); } else if (type == 'i') { Console.Write("Customs fee: "); double customsFee = double.Parse(Console.ReadLine()); ImportedProduct imported = new ImportedProduct(name, price, customsFee); list.Add(imported); } else { Product product = new Product(name, price); list.Add(product); } } Console.WriteLine(); Console.WriteLine("PRICE TAGS:"); foreach (Product prod in list) { Console.WriteLine(prod.PriceTag()); } }