Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- namespace ProductInventory
- {
- public enum InventoryState
- {
- Full,
- Selling,
- Stocking,
- Empty,
- Unassigned
- }
- public class Product
- {
- public string GetProductDirectory(string productName)
- {
- string finalPath = $"{Environment.CurrentDirectory}\\products\\{productName}.txt";
- return finalPath;
- }
- public string ProductType;
- public double BulkPrice;
- public double RetailPrice;
- public int Quantity;
- public int MaxQuantity;
- public InventoryState Status;
- public string FileName;
- // defining the parameters for the constructor
- public Product(string FileName)
- {
- this.FileName = GetProductDirectory(FileName);
- ProductType = File.ReadLines(FileName).ElementAt(1);
- BulkPrice = Double.Parse(File.ReadLines(FileName).ElementAt(2));
- RetailPrice = Double.Parse(File.ReadLines(FileName).ElementAt(3));
- Quantity = Int32.Parse(File.ReadLines(FileName).ElementAt(4));
- MaxQuantity = Int32.Parse(File.ReadLines(FileName).ElementAt(5));
- } // the constructor
- }
- public class Program
- {
- public static string[] CommandList =
- {
- "status",
- "help",
- "exit"
- };
- public static Product[] ProductList =
- {
- new Product("Apple"),
- new Product("Blueberry")
- }; // TODO: make these values based on text files
- public static void Main()
- {
- string inputCommand, unformattedProduct, selectedProduct, stringStatus;
- bool isProduct = false;
- foreach (Product productName in ProductList)
- {
- if (productName.Quantity == productName.MaxQuantity)
- {
- productName.Status = InventoryState.Full;
- }
- else if (productName.Quantity <= (productName.MaxQuantity * (0.5)))
- {
- productName.Status = InventoryState.Stocking;
- }
- else if (productName.Quantity == 0)
- {
- productName.Status = InventoryState.Empty;
- }
- else
- {
- productName.Status = InventoryState.Selling;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement