예제 #1
0
        public void DisplaySoldInventoryItems()
        {
            try
            {
                int increment = 0;

                NodeClass current = first;

                while (current != null)
                {
                    increment++;

                    if (current.soled == true)
                    {
                        increment++;
                        Console.WriteLine("Inventory Item " + increment + "  => " + " [" + "name:" + current.name + " , " + " Price:" + " $" + current.price + ",  Discription:" + current.discription + " , SOLED " + current.soled + " ] ");
                    }
                    current = current.NextNode;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
예제 #2
0
        internal void BuyItem(string item, int paymentAmount, InventoryItemClass counter)
        {
            int       temp     = 0;
            NodeClass tempNode = null;

            NodeClass data = inventoryItem;

            while (data != null)
            {
                if (data.name == item && data.soled == false)
                {
                    if (PaymentSuccess(paymentAmount) == true)
                    {
                        itemBought[0] = item;
                        tempNode      = data;
                        temp++;
                        counter.count--;
                        data.itemSold();
                    }
                }

                data = data.NextNode;
            }

            if (temp == 1)
            {
                Console.WriteLine(name + " just bought an or a " + " [ " + tempNode.name + " ] " + " computer");
            }

            if (temp == 0)
            {
                Console.WriteLine(name + " tries to buy an item,  but it is " + " 0ut  of  stock");
            }
        }
예제 #3
0
 public Customer(string id, string name, string customerLocation, NodeClass inventoryItem)
 {
     this.name             = name;
     this.id               = Int32.Parse(id);
     this.customerLocation = customerLocation;
     this.inventoryItem    = inventoryItem;
     this.itemBought       = new string[12];
 }
예제 #4
0
        public bool DeleteItem(string name)
        {
            NodeClass current    = first;
            NodeClass oldCurrent = first;

            bool temp = false;

            while (current != null)
            {
                if (current.NextNode != null)
                {
                    oldCurrent = current;

                    current = current.NextNode;

                    if (oldCurrent.NextNode == current)
                    {
                        Console.WriteLine("current node  is " + current.name + " && old node is " + oldCurrent.name);

                        if (oldCurrent.name == name)
                        {
                            Console.WriteLine("It is true " + current.name + " is reached ");
                            first = current;
                            temp  = true;
                            count--;
                            break;
                        }
                        if (current.name == name)
                        {
                            Console.WriteLine("It is true " + current.name + " is reached ");
                            oldCurrent.NextNode = current.NextNode;
                            temp = true;
                            count--;
                            break;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("current node  is " + current.name + " && old node is " + oldCurrent.name);

                    if (current.name == name)
                    {
                        Console.WriteLine("It is true " + current.name + " is reached ");
                        oldCurrent.NextNode = current.NextNode;
                        temp = true;
                        count--;
                        break;
                    }
                }



                current = current.NextNode;
            }
            return(temp);
        }
예제 #5
0
 public NodeClass(string name, string price, string condition, string modal, string discription, bool soled)
 {
     this.name        = name;
     this.price       = price;
     this.condition   = condition;
     this.modal       = modal;
     this.discription = discription;
     this.soled       = false;
     this.NextNode    = null;
 }
예제 #6
0
        public void UpdatePrice(string name, string amount, NodeClass DataBase)
        {
            bool   item     = FindItem(name);
            string oldPrice = findPrice(name);

            if (item == true)
            {
                Console.WriteLine("Original price of (" + name + ")  is " + oldPrice + " new Updated  price  is ==> " + UpdateInventory(name, amount, DataBase));
            }
            else
            {
                Console.WriteLine("It is Not found or has  been sold");
            }
        }
예제 #7
0
        public bool  FindItem(string name)
        {
            bool      temp    = false;
            NodeClass current = first;

            while (current != null)
            {
                if (current.name == name && current.soled != true)
                {
                    temp = true;
                }

                current = current.NextNode;
            }

            return(temp);
        }
예제 #8
0
        public string findPrice(string name)
        {
            string    temp    = "";
            NodeClass current = first;

            while (current != null)
            {
                if (current.name == name && current.soled != true)
                {
                    temp = current.price;
                }

                current = current.NextNode;
            }

            return(temp);
        }
예제 #9
0
        public string  UpdateInventory(string name, string price, NodeClass dataBase)
        {
            NodeClass current  = dataBase;
            string    newPrice = "";

            while (current != null)
            {
                if (current.name == name && current.soled != true)
                {
                    current.price = price;
                    return(price);
                }

                current = current.NextNode;
            }

            return(newPrice);
        }
예제 #10
0
        public void Insert(string name, string price, string condition, string modal, string discription, bool soled)
        {
            NodeClass current = first;

            NodeClass newNode = new NodeClass(name, price, condition, modal, discription, soled);

            if (current != null)
            {
                newNode.NextNode = first;

                first = newNode;
                count++;
            }
            if (current == null)
            {
                first = newNode;
                count++;
            }
        }
예제 #11
0
 public InventoryItemClass() : base("1334", "James", true)
 {
     this.first = null;
     this.count = 0;
 }