public void add(iTool aTool)
        {
            Console.WriteLine("Select the category");
            for (int i = 0; i < categories.Length; i++)
            {
                Console.WriteLine(i + 1 + ". " + categories[i].Name);
            }
            Console.Write("Select the option from menu: ");

            int categoryIndex = Convert.ToInt32(Console.ReadLine()) - 1;

            Console.WriteLine("");
            Console.WriteLine("");
            Console.WriteLine("Select the tool type");
            Console.WriteLine("=============================");
            for (int i = 0; i < categories[categoryIndex].Types.Length; i++)
            {
                Console.WriteLine(i + 1 + ". " + categories[categoryIndex].Types[i].Name);
            }
            Console.WriteLine("Selection option from menu");
            int typeIndex = Convert.ToInt32(Console.ReadLine()) - 1;

            categories[categoryIndex].Types[typeIndex].Tools.add(aTool);
            Console.WriteLine("Tool successfully added to library");
            Console.WriteLine("");
            Console.WriteLine("Hit enter to continue");
            Console.ReadLine();
        }
Exemple #2
0
        public void delete(iTool aTool) //delte a given tool from the system
        {
            iToolCollection currentToolCollection = MainMenu.currentToolType;

            Console.WriteLine(aTool.ToString());
            currentToolCollection.delete(aTool);
        }
Exemple #3
0
        public void addTool(iTool aTool)
        {
            BinarySearchTree tree = new BinarySearchTree()
            ;

            tree.Insert(aTool);
        }
Exemple #4
0
        public void add(iTool aTool) // add a new tool to the system
        {
            iToolCollection currentToolCollection = MainMenu.currentToolType;

            Console.WriteLine(aTool.ToString());
            currentToolCollection.add(aTool);
        }
Exemple #5
0
 public void deleteTool(iTool aTool) //delete a given tool from the list of tools that this member is currently holding
 {
     if (toolsBorrowed.Remove(aTool) == false)
     {
         Console.Write("The tool selected is not borrowed by this member, press anykey to return...");
         Console.ReadKey();
     }
 }
Exemple #6
0
 public Job(Job job)
 {
     this.id             = job.Id;
     this.prerequisite   = job.Prerequisite;
     this.title          = job.Title;
     this.operation      = job.operation;
     this.when           = job.when;
     this.associatedTool = IdentifyTool();
 }
Exemple #7
0
 public Job(int id, int prerequisite, string title, string operation, DateTime when, SPAttachmentCollection attachments)
 {
     this.id             = id;
     this.prerequisite   = prerequisite;
     this.title          = title;
     this.operation      = operation;
     this.when           = when;
     this.attachments    = AddAttachments(attachments);
     this.associatedTool = IdentifyTool();
 }
Exemple #8
0
            iTool minValue(Node root)
            {
                iTool minv = root.Data;

                while (root.Left != null)
                {
                    minv = root.Left;
                    root = root.Left;
                }
                return(minv);
            }
        //static public void MergeSort(iTool[] toolArray)
        //{
        //    // Sorts (sub)array A into nondecreasing order, from position i
        //    // to position j, inclusive
        //    int middle;
        //    int endArray = toolArray.Length - 1;
        //    int startArray = 0;

        //    if (startArray < endArray)
        //    {
        //        middle = Math.Abs((startArray + endArray) / 2);
        //        MergeSort(toolArray[startArray..middle]);
        //        MergeSort(toolArray[(middle+1)..endArray]);
        //        Merge(ref toolArray, middle);
        //    }
        //    return;
        //}

        //static public void Merge(ref iTool[] toolArray, int middle)
        //{
        //    int endArray = toolArray.Length - 1;//j
        //    int startArray = 0; //p
        //    int tempIndexer = 0;//r
        //    int startArray2 = middle + 1;//q
        //    iTool[] temp = new iTool[toolArray.Length];

        //    while (startArray <= middle && startArray2 <= endArray)
        //    {
        //        if (toolArray[startArray].NoBorrowings <= toolArray[startArray2].NoBorrowings)
        //        {
        //            temp[tempIndexer] = toolArray[startArray];
        //            startArray++;
        //        }
        //        else
        //        {
        //            temp[tempIndexer] = toolArray[startArray2];
        //            startArray2++;
        //        }

        //        tempIndexer++;

        //        if (startArray <= middle)
        //        {
        //            int sourceIndex = startArray;
        //            int destinationIndex = tempIndexer;
        //            Array.Copy(toolArray, sourceIndex, temp, destinationIndex, middle - startArray);
        //        }
        //        if (startArray2 <= endArray)
        //        {
        //            int sourceIndex = startArray2;
        //            int destinationIndex = tempIndexer;
        //            Array.Copy(toolArray, sourceIndex, temp, destinationIndex, endArray - startArray);
        //        }
        //        toolArray = temp;
        //    }
        //}

        public static iTool[] mergeSort(iTool[] array)
        {
            iTool[] left;
            iTool[] right;
            iTool[] result = new iTool[array.Length];
            //As this is a recursive algorithm, we need to have a base case to
            //avoid an infinite recursion and therfore a stackoverflow
            if (array.Length <= 1)
            {
                return(array);
            }
            // The exact midpoint of our array
            int midPoint = array.Length / 2;

            //Will represent our 'left' array
            left = new iTool[midPoint];

            //if array has an even number of elements, the left and right array will have the same number of
            //elements
            if (array.Length % 2 == 0)
            {
                right = new iTool[midPoint];
            }
            //if array has an odd number of elements, the right array will have one more element than left
            else
            {
                right = new iTool[midPoint + 1];
            }

            //populate left array
            for (int i = 0; i < midPoint; i++)
            {
                left[i] = array[i];
            }
            //populate right array
            int x = 0;

            //We start our index from the midpoint, as we have already populated the left array from 0 to midpont
            for (int i = midPoint; i < array.Length; i++)
            {
                right[x] = array[i];
                x++;
            }
            //Recursively sort the left array
            left = mergeSort(left);
            //Recursively sort the right array
            right = mergeSort(right);
            //Merge our two sorted arrays
            result = merge(left, right);
            return(result);
        }
        //This method will be responsible for combining our two sorted arrays into one giant array
        private static iTool[] merge(iTool[] left, iTool[] right)
        {
            int resultLength = right.Length + left.Length;

            iTool[] result = new iTool[resultLength];
            //
            int indexLeft = 0, indexRight = 0, indexResult = 0;

            //while either array still has an element
            while (indexLeft < left.Length || indexRight < right.Length)
            {
                //if both arrays have elements
                if (indexLeft < left.Length && indexRight < right.Length)
                {
                    //If item on left array is less than item on right array, add that item to the result array
                    if (left[indexLeft].NoBorrowings >= right[indexRight].NoBorrowings)
                    {
                        result[indexResult] = left[indexLeft];
                        indexLeft++;
                        indexResult++;
                    }
                    // else the item in the right array wll be added to the results array
                    else
                    {
                        result[indexResult] = right[indexRight];
                        indexRight++;
                        indexResult++;
                    }
                }
                //if only the left array still has elements, add all its items to the results array
                else if (indexLeft < left.Length)
                {
                    result[indexResult] = left[indexLeft];
                    indexLeft++;
                    indexResult++;
                }
                //if only the right array still has elements, add all its items to the results array
                else if (indexRight < right.Length)
                {
                    result[indexResult] = right[indexRight];
                    indexRight++;
                    indexResult++;
                }
            }
            return(result);
        }
Exemple #11
0
        public void add(iTool aTool) //add a given tool to this tool collection
        {
            bool matched = false;

            foreach (Tool tool in toolCollection)
            {
                if (aTool.Name == tool.Name)
                {
                    tool.Quantity = aTool.Quantity;
                    matched       = true;
                    break;
                }
            }
            if (!matched)
            {
                toolCollection.Add(aTool);
            }
        }
Exemple #12
0
        public void delete(iTool aTool) //delete a given tool from this tool collection
        {
            bool matched = false;

            foreach (Tool tool in toolCollection)
            {
                if (aTool == tool)
                {
                    toolCollection.Remove(aTool);
                    matched = true;
                    break;
                }
            }
            if (!matched)
            {
                Console.Write("\nThe heck?!? it wasnt found,npress anykey to continue...");
                Console.ReadKey();
            }
        }
Exemple #13
0
        public void delete(iTool aTool, int quantity)
        {
            iToolCollection currentToolCollection = MainMenu.currentToolType;
            List <iTool>    toolList = currentToolCollection.ToolCollectionList;

            iTool[] toolArray = currentToolCollection.toArray();
            int     i         = 0;

            foreach (var tool in toolArray)
            {
                if (tool.Name == aTool.Name)
                {
                    break;
                }
                i++;
            }

            toolList[i].Quantity = -quantity;
        }
Exemple #14
0
        public void add(iTool aTool, int quantity) //add new pieces of an existing tool to the system
        {
            iToolCollection currentToolCollection = MainMenu.currentToolType;
            List <iTool>    toolList = currentToolCollection.ToolCollectionList;

            iTool[] toolArray = currentToolCollection.toArray();
            int     i         = 0;

            foreach (var tool in toolArray)
            {
                if (tool.Name == aTool.Name)
                {
                    break;
                }
                i++;
            }

            toolList[i].Quantity = quantity;
        }
Exemple #15
0
            Node deleteRec(Node root, iTool tool)
            {
                // Base Case: If the tree is empty
                if (root == null)
                {
                    return(root);
                }

                // Otherwise, recur down the tree

                // Determine which branch should we continue to trace down.
                if (!tool.Equals(root.Data))
                {
                    root.Left = deleteRec(root.Left, tool);
                }
                else if (!tool.Equals(root.Data))
                {
                    root.Right = deleteRec(root.Right, tool);
                }

                // if tool is same as root's tool, then This is the node   to be deleted
                else
                {
                    // node with only one child or no child
                    if (root.Left == null)
                    {
                        return(root.Right);
                    }
                    else if (root.Right == null)
                    {
                        return(root.Left);
                    }

                    // node with two children: Get the inorder successor (smallest in the Right subtree)

                    root.Data = minValue(root.Right);

                    // Delete the inorder successor
                    root.Right = deleteRec(root.Right, root.Data);
                }
                return(root);
            }
Exemple #16
0
 public void borrowTool(iMember aMember, iTool aTool) //a member borrows a tool from the tool library
 {
     if (aMember.Tools.Length >= 3)
     {
         Console.Write("You currently have three(3) tools on loan, please return one before renting another. " +
                       "Press anykey to return...");
         Console.ReadKey();
         return;
     }
     else if (aTool.AvailableQuantity <= 0)
     {
         Console.Write("The tool selected is unavalible, please wait for someone to return this tool. " +
                       "Press anykey to return...");
         Console.ReadKey();
         return;
     }
     else
     {
         aMember.addTool(aTool);
         aTool.addBorrower(aMember);
     }
 }
Exemple #17
0
            public void Insert(iTool itool)
            {
                Node newNode = new Node();

                newNode.Data = itool;
                if (root == null)
                {
                    root = newNode;
                }
                else
                {
                    Node current = root;
                    Node parent;
                    while (true)
                    {
                        parent = current;
                        if (itool.Equals(current.Data))
                        {
                            current = current.Left;
                            if (current == null)
                            {
                                parent.Left = newNode;
                                break;
                            }

                            else
                            {
                                current = current.Right;
                                if (current == null)
                                {
                                    parent.Right = newNode;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
 public bool search(iTool aTool)
 {
     return(this.tools.Contains(aTool));
 }
 public void delete(iTool aTool)
 {
     this.tools.Remove(aTool);
 }
 public void add(iTool aTool)
 {
     this.tools.Add(aTool);
 }
Exemple #21
0
 public void add(iTool aTool)
 {
     throw new NotImplementedException();
 }
Exemple #22
0
 public void returnTool(iMember aMember, iTool aTool)
 {
     throw new NotImplementedException();
 }
Exemple #23
0
 public Boolean search(iTool aTool) //search a given tool in this tool collection. Return true if this tool is in the tool collection; return false otherwise
 {
     return(toolCollection.Contains(aTool));
 }
Exemple #24
0
 public void returnTool(iMember aMember, iTool aTool) //a member return a tool to the tool library
 {
     aMember.deleteTool(aTool);
     aTool.deleteBorrower(aMember);
 }
Exemple #25
0
 public void delete(iTool aTool, int quantity)
 {
     throw new NotImplementedException();
 }
Exemple #26
0
 public void addTool(iTool aTool) //add a given tool to the list of tools that this member is currently holding
 {
     toolsBorrowed.Add(aTool);
 }
Exemple #27
0
 public void deleteTool(iTool aTool)
 {
     throw new NotImplementedException();
 }
Exemple #28
0
 public bool search(iTool aTool)
 {
     throw new NotImplementedException();
 }