Please note, that this is not a homework site.
We won't do your homework for you.
The purpose of homework is that you learn by doing.
However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.
We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
Hi,
We are not here to do home works :|
if you need any help about starting project and how to write classes, you're welcome, but if you want to get hole complete project, im sorry, i cant do it.
**NOTE: if you want to start, its my first guide, think its a simple LinkedList, and Contact class is your node, so, code it as a node for your Linked list (i mean, you should have a pointer in that class, like node *next; ).
then ContactList, is your LinkedList class, so, you need an Obj, and *head (Or any other way you prefer to define a Linked list)
and finally, use them in MobilePhone class.
if you need help to code them, feel free to ask, but start coding at first by your self.
Okay, so this is what I got so far. Please help if you can and add good comments. I think I'm getting it but still unsure.
Design requirements:
1. Create a new class type called Contact. The purpose of the Contact class is to model a single contact in a phone contact list.
The Contact type should have the following attributes:
2. Create a new class type called ContactList. The purpose of the ContactList class is to manage an array of contacts. The ContactList
class should have the following characteristics:
a. An attribute should be defined to contain an array of Contact instances.
b. The constructor function of the class should initialize the array of Contacts to 10 elements in size.
c. There should be a function called AddContact. The function should accept a Contact as a parameter. When invoked, the function will
assign the Contact into the array into the appropriate element that will maintain the list in sorted order by last name. The function
does not return anything. If there are not enough slots left in the array to store the contact, then the original array should be
replaced by a new array that is double in size. You will need to keep track of how large your array was made.
d. There should be a function called FindContact. The function should accept two strings that represent the first and last name to search
for. If there is a contact in the array that matches the first and last name given, then the function should return the phone number
of the contact that was matched. Otherwise, the function should return an empty string (“”).
e. There should be a function called GetCount. This function should simply return how many contacts were added to the array.
f. There should be a function called GetSize. The function should return the capacity of the contact list (how big the array currently is).
Function ContactListSort (ref ContactList[ ].l, Int arraySize)
//Contains the last subscript of the last element to be compared within the array.
DECLARE integer maxElement;
//This is used as a counter in the loop.
DECLARE integer index;
//maxElement is set at the end of the array to be compared during each pass of the
//array. It is initially set as the index of the last element and then it decreases by one
//with each iteration.
FOR maxElement = arraySize - 1 to 0 Step -1;
//The inner loop goes through the array two at a time and compares adjacent
// elements. All the elements from 0 to maxElement are compared. If they are
// out of order, the module sends them to another sub module to be swapped.
FOR index = 0 to maxElement - 1;
//Compares two adjacent array elements and swaps if necessary.
IF array [index] > array [index + 1] THEN;
Call swap array[index], array[index + 1];
END IF;
END FOR;
END FOR;
END MODULE
// This is the actual swapping Module for the bubbleSort.
MODULE CompareContacts(String Ref ContactList.l1, String Ref ContactList.l2)
// Temporarily holds a value while it is swapped.
DECLARE String temp;
//Swap the values in ContactList.l1 and ContactList.l2
SET temp = ContactList.l1;
SET ContactList.l1 = ContactList.l2;
SET ContactList.l2 = temp;
Your ContactList class should also have an attribute such as size to keep track of the size of your dynamic array.
//Defines the qualities of the Class with F, L and P
Int f,l,p
This doesn't belong in ContactList class or in the constructor function ContactList(). Not sure what it's supposed to do...
//
NumbersAdded = ref AddContact intCount
You didn't comment anything here so I'm assuming that NumbersAdded is an attribute of your ContactList class to keep track of how much of the dynamic array is actually filled.
Declare ContactList[] = Count
Huh?
//Sets up a counter with limit to 10 instance
From 0 - 9 Count
//Keeping constraint on the Contact List
If Count < 9 then;
//User interface
Print "Would you like to add a new contact?";
InputY = Yes;
InputN = No;
//Error Message
If Input != InputY, InputN, then;
Print "Please try again.";
End if
Print "Enter First Name";
ContactList[Count].f = First Name;
Print "Enter Last Name";
ContactList[Count].l = Last Name;
Instead of 9, use size (the attribute in the ContactList class that you should have had). Instead of ContactList[Count], it should be phoneBook[Count]. According to requirements, you are supposed to have a check here for how many contacts have been added. If the phoneBook[] is full, double the size of the array.