Monday 3 June 2013

PLEASE HELP With Phonebook Program! - C And C++ | Dream.In ...


Example
#{example}
"); ipb.editor_values.get('templates')['togglesource'] = new Template("
??? Cancel Source Edit
"); ipb.editor_values.get('templates')['toolbar'] = new Template(""); ipb.editor_values.get('templates')['button'] = new Template("
  • Icon
  • "); ipb.editor_values.get('templates')['menu_item'] = new Template("
  • #{title}
  • "); ipb.editor_values.get('templates')['togglesource'] = new Template("
    ??? Cancel Source Edit
    "); ipb.editor_values.get('templates')['emoticons_showall'] = new Template(""); ipb.editor_values.get('templates')['emoticon_wrapper'] = new Template("

    Emoticons

    "); // Add smilies into the mix ipb.editor_values.set( 'show_emoticon_link', false ); ipb.editor_values.set( 'bbcodes', $H({"snapback":{"id":"1","title":"Post Snap Back","desc":"This tag displays a little linked image which links back to a post - used when quoting posts from the board. Opens in same window by default.","tag":"snapback","useoption":"0","example":"[snapback]100[/snapback]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"topic":{"id":"5","title":"Topic Link","desc":"This tag provides an easy way to link to a topic","tag":"topic","useoption":"1","example":"[topic=1]Click me![/topic]","switch_option":"0","menu_option_text":"Enter the topic ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"post":{"id":"6","title":"Post Link","desc":"This tag provides an easy way to link to a post.","tag":"post","useoption":"1","example":"[post=1]Click me![/post]","switch_option":"0","menu_option_text":"Enter the Post ID","menu_content_text":"Enter the title for this link","single_tag":"0","optional_option":"0","image":""},"spoiler":{"id":"7","title":"Spoiler","desc":"Spoiler tag","tag":"spoiler","useoption":"0","example":"[spoiler]Some hidden text[/spoiler]","switch_option":"0","menu_option_text":"","menu_content_text":"Enter the text to be masked","single_tag":"0","optional_option":"0","image":""},"acronym":{"id":"8","title":"Acronym","desc":"Allows you to make an acronym that will display a description when moused over","tag":"acronym","useoption":"1","example":"[acronym='Laugh Out Loud']lol[/acronym]","switch_option":"0","menu_option_text":"Enter the description for this acronym (EG: Laugh Out Loud)","menu_content_text":"Enter the acronym (EG: lol)","single_tag":"0","optional_option":"0","image":""},"hr":{"id":"12","title":"Horizontal Rule","desc":"Adds a horizontal rule to separate text","tag":"hr","useoption":"0","example":"[hr]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"1","optional_option":"0","image":""},"php":{"id":"14","title":"PHP Code","desc":"Allows you to enter PHP code into a formatted/highlighted syntax box","tag":"php","useoption":"0","example":"[php]$variable = true;\n\nprint_r($variable);[/php]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"html":{"id":"15","title":"HTML Code","desc":"Allows you to enter formatted/syntax-highlighted HTML code","tag":"html","useoption":"0","example":"[html]\n \n[/html]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"sql":{"id":"16","title":"SQL Code","desc":"Allows you to enter formatted/syntax-highlighted SQL code","tag":"sql","useoption":"0","example":"[sql]SELECT p.*, t.* FROM posts p LEFT JOIN topics t ON t.tid=p.topic_id WHERE t.tid=7[/sql]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"xml":{"id":"17","title":"XML Code","desc":"Allows you to enter formatted/syntax-highlighted XML code","tag":"xml","useoption":"0","example":"[xml]\n \n Test\n \n[/xml]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"member":{"id":"31","title":"Member","desc":"Given a member name, a link is automatically generated to the member's profile","tag":"member","useoption":"1","example":"[member=skyhawk133] runs this site.","switch_option":"0","menu_option_text":"Input Username of Member","menu_content_text":"","single_tag":"1","optional_option":"0","image":"memberbbcode.png"},"extract":{"id":"33","title":"Extract Blog Entry","desc":"This will allow users to define an extract for an entry. Only this piece of the entry will be displayed on the main blog page and will show up in the RSS feed.","tag":"extract","useoption":"0","example":"[extract]This is an example![/extract]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"blog":{"id":"34","title":"Blog Link","desc":"This tag provides an easy way to link to a blog.","tag":"blog","useoption":"1","example":"[blog=100]Click me![/blog]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"entry":{"id":"35","title":"Blog Entry Link","desc":"This tag provides an easy way to link to a blog entry.","tag":"entry","useoption":"1","example":"[entry=100]Click me![/entry]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"twitter":{"id":"36","title":"Twitter","desc":"A tag to link to a user's twitter account","tag":"twitter","useoption":"0","example":"[twitter]userName[/twitter]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"twitter.png"},"inline":{"id":"37","title":"Inline Code","desc":"Formats code inline instead of in a seperate code box. ","tag":"inline","useoption":"0","example":"[inline]style=\"font-size: 12px;\"[/inline]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":""},"il":{"id":"38","title":"Abbreviated Inline (IL)","desc":"Abbreviated version of the [inline] tag. ","tag":"il","useoption":"0","example":"[il]Code Here[/il]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"0","image":"il2.png"},"code":{"id":"41","title":"Code","desc":"Allows you to enter general code","tag":"code","useoption":"1","example":"[code]$text = 'Some long code here';[/code]","switch_option":"0","menu_option_text":"","menu_content_text":"","single_tag":"0","optional_option":"1","image":""}}) ); ipb.vars['emoticon_url'] = "http://cdn.dreamincode.net/forums/public/style_emoticons/default"; //Search Setup ipb.vars['search_type'] = 'forum'; ipb.vars['search_type_id'] = 15; ipb.vars['search_type_2'] = 'topic'; ipb.vars['search_type_id_2'] = 322344; //]]>

    1 Replies - 0 Views - Last Post: Today, 10:54 AM Rate Topic: -----

    #1 mimicocoapuff ?Icon User is online

    Reputation: 0

    • Posts: 1
    • Joined: Today, 10:48 AM

    Posted Today, 10:53 AM

    Hello!

    I am new to this forum and very new to C++. I am currently taking a C++ programming class, and I could really use some help with a program.

    I already completed the first part of the assignment, in which I
    implemented a software-based directory to replace AT&T paper phonebooks. I will include my code for this below.

    PROBLEM: AT&T has decided paper phone books are stupid and wasteful. They wanted you to implement a software-based directory instead. So you did this. (This was the previous assignment, which I completed). Unfortunately, the job of a software developer is never complete, and AT&T had some modifications for you to make.
    You coded a system which uses a static array of pointers to reference the phonebook?s DirectoryEntry objects. Unfortunately, that had a fixed size of 100, and AT&T wasn?t happy with that. They want you to instead implement a new DirectoryEntriesList class which functions as a linked list to encapsulate and organize your DirectoryEntry objects. This will replace the old DirectoryEntry array.
    New .h files have been posted. There is a directoryentrieslist.h file, which
    contains the interface to the DirectoryEntriesList class. It also contains very
    slightly modified phonebook.h and directoryentry.h files.

    Here is the new work you must complete for full credit in this assignment:
    1) Implement the DirectoryEntriesList class methods given in
    directoryentrieslist.h.
    2) Modify your old .cpp (phonebook.cpp and directoryentry.cpp) files to properly
    work with the new linked list DirectoryEntriesList object.

    __________________

    Here is the directoryentrieslist.h header file (they provided):

    
 #ifndef DIRECTORY_ENTRY_LIST_H #define DIRECTORY_ENTRY_LIST_H  #include <string> #include "directoryentry.h"  using namespace std;  class DirectoryEntriesList{ public: 	//Constructor; initially empty 	DirectoryEntriesList();  	//Destructor 	~DirectoryEntriesList();  	//Returns the size of the linked list 	int size();  	//Print the linked list in ascending order by Name to std out 	void print();    	//Insert a new directory entry. The DirectoryEntriesList should always remain in ascending order by Name. 	void insert(DirectoryEntry& t);  	//Returns a pointer to the DirectoryEntry with the given Name, or NULL (0) if there is no such entry 	DirectoryEntry* find(string const& Name);  	//Removes the directory entry with the given Name. 	void remove(string const& Name);  private: 	//Pointer to the first element in the directory entry linked list 	DirectoryEntry *pDirectoryEntry; };  #endif  

    Here is the directoryentry.h header file (they provided):

    
 #ifndef DIRECTORY_ENTRY_H #define DIRECTORY_ENTRY_H  #include <string>  using namespace std;  class DirectoryEntry{ public: 	//Constructor 	DirectoryEntry( string const& name, string const& number );  	//Destructor 	~DirectoryEntry(); 	 	//Getters 	string getName(); 	string getNumber();  	//The pointer to the next element in the linked list 	DirectoryEntry * next;  private: 	//Person's name 	string name;  	//Person's phone number 	string number; };  #endif  

    Here is my directoryofentry.cpp file from the last assignment:

    
  #include <iostream> #include "stdafx.h" #include "directoryentry.h" #include "string" using namespace std;  string DirectoryEntry::getName() { 	return name; }  string DirectoryEntry::getNumber() { 	return number; } 

    Here is the phonebook.h header file (they provided):

    
 #ifndef PHONEBOOK_H #define PHONEBOOK_H   #include <string> #include "directoryentrieslist.h"  using namespace std;  class Phonebook{ public: 	//Constructor 	Phonebook(); 	 	//Destructor 	~Phonebook();  	//Loads the data from the given filename into the private DirectoryEntriesList. 	void loadData(string const& filename);  	//Returns  the number associated with 'name'. 	string lookupName( string const& name );  	//If 'name' already exists in the directory, change his number to 'number'. Otherwise, create a new directory entry with the given 'name' and 'number'. Return true iff the 'name' already exists. 	bool addChangeEntry(string const& name, string const& number );  	//If 'name' exists in the directory, remove his name/number. Return true iff 'name' already exists. 	bool removeEntry(string const& name );  	//Write all changes back to the file that we opened from. 	bool save();  	//Print all names/numbers in the directory. 	void printAll();  private: 	//Returns the index in 'directoryEntries' where the entry with name 'name' exists. Returns -1 if it cannot be found. Use this function when implementing some of the public functions. 	int findName( string const& name );  	//Our linked list of directory entries. 	DirectoryEntriesList directoryEntries;  	//Current number of entries in the phone book 	int numEntries;  	//Where our data was loaded from. 	string sourceFilename; };  #endif  

    Here is my phonebook.cpp file from the last assignment:

    
 #include <iostream> #include "fstream" #include "stdafx.h" #include <cstdlib> #include "string" #include "phonebook.h" #include "directoryentry.h" using namespace std;  int l = 0; void Phonebook::loadData(string const& filename) { 	string line; 	ifstream in_file; 	in_file.open(filename); 	sourceFilename = filename; 	string s[200]; 	while (getline(in_file,line)) 	{ 		s[l] = line; 		l++; 	} 	in_file.close();  	numEntries = l/2; 	for (int count=0; count<numEntries; count++) 	{ 		this->directoryEntries[count] = new DirectoryEntry(s[count*2], s[count*2+1]); 	}  }  string Phonebook::lookupName(string const& name) { 	for (int count=0; count<numEntries; count++) 	{ 		if (directoryEntries[count]->getName() == name) 		{ 			return directoryEntries[count] -> getNumber(); 		} 	} 	return "THIS NAME DOES NOT EXIST!";  }  //If 'name' already exists in the directory, change his number to 'number'. Otherwise, create a new directory entry with the given 'name' and 'number'. Return true iff the 'name' already exists. bool Phonebook::addChangeEntry(string const& name, string const& number) { 	for (int count=0; count<numEntries; count++) 	{ 		if (directoryEntries[count]->getName() == name) 		{ 			this -> directoryEntries[count] = new DirectoryEntry(name, number); 			return true; 		} 	} 	this -> directoryEntries[numEntries] = new DirectoryEntry(name, number); 	numEntries++; 	return false; }  //If 'name' exists in the directory, remove his name/number. Return true iff 'name' already exists. bool Phonebook::removeEntry(string const& name) { 	for (int count = 0; count<numEntries; count++) 	{ 		if (directoryEntries[count]->getName() == name) 		{ 			directoryEntries[count] = directoryEntries[count+1]; 			numEntries--; 			return true; 		} 	} 	return false; }  //Write all changes back to the file that we opened from. bool Phonebook::save() { 	ofstream out_file; 	out_file.open(sourceFilename); 	for (int count=0; count<numEntries; count++) 	{ 		out_file << directoryEntries[count] -> getName() << endl; 		out_file << directoryEntries[count] -> getNumber() << endl; 	} 	return true; }  //Print all names/numbers in the directory. void Phonebook::printAll() { 	ifstream in_file; 	in_file.open(sourceFilename); 	string line; 	while (getline(in_file,line)) 	{ 		cout << line << endl; 	} } 

    I know all of it is lengthy, but I would be REALLY grateful if someone could please help me out! I could probably figure it out if I sat down and worked on it for long enough, but I'm on a time crunch and I have a lot of other exams to study for, so your help would go a long way for me.

    Thank you so much!
    - Miranda


    Is This A Good Question/Topic? 0

    Replies To: PLEASE HELP with Phonebook Program!

    #2 macosxnerd101 ?Icon User is online

    Reputation: 9076

    • Posts: 33,683
    • Joined: 27-December 08

    Re: PLEASE HELP with Phonebook Program!

    Posted Today, 10:54 AM

    What specific questions do you have? We're happy to help, but you need to be more specific as to your questions. A general dump of your project spec and code is pretty broad.


    Page 1 of 1


    Source: http://www.dreamincode.net/forums/topic/322344-please-help-with-phonebook-program/

    bully bohemian rhapsody bohemian rhapsody spike lee carson daly heejun han donovan mcnabb

    No comments:

    Post a Comment