473,806 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

combining two projects

1 New Member
hi there, how are you doing all? i am a beginner user in c++ our teacher asked some question i did the first part... and i have donw something similar for second part but i dont know how to combine them.. the question was...
Add a record to the list
Remove a Record object from the list
Find a Record object, given the last name
View all Record objects.

Make sure that your program is menu driven with an attractive user interface.

i did the assignment as this...

#include <iostream>
#include <string>

using namespace std;

//define shortName class

class shortName {

private:

string name;

public:

void setName(string new_name) {name = new_name;}

string getName () {
return "Name:" + name;}
};
//define shortAddress class

class shortAddress {

private
:

string address;

public
:

void setAddress(stri ng new_address) {address = new_address;}

string getAddress () {
return "Address:"+addr ess;}

};

//define shortPhone class

class shortPhone {

private
:

string phone;

public
:

void setPhone(string new_phone) {phone = new_phone;}

string getPhone () {return "Phone:"+phone; }

};

//define Record class which combines the three classes defined above

class Record {

private
:

shortName Name;

shortAddress Address;

shortPhone Phone;

public
:

Record (string name, string address, string phone) {Name.setName(n ame); Address.setAddr ess(address); Phone.setPhone( phone);};

//print out the record information to screen

void print_record() {

cout <<Name.getName( )<<endl;

cout <<Address.getAd dress()<<endl;

cout <<Phone.getPhon e()<<endl;

}

};

int main (void) {

string name, address, phone;

cout <<"Enter your name:";

cin >>name;

cout <<"Enter your address:";

cin >>address;

cout <<"Enter your phone number:";

cin >> phone;

Record myRecord(name, address , phone);

myRecord.print_ record();



}

and we did something like that in the class


#include <iostream>
#include <string>
using namespace std;

//Declare Functions...

int GetNames(string[], int);
string FindName(string[], int);
string DeleteName(stri ng[], int);
void ShowNames(strin g[], int);
void Sort(string[], int);
void Menu();

int main()
{
const int Size = 25; //You need a const to use it with the
// array.
string List[Size];
int Count;

string Result, Cmd;

for( ; ; ) {
Menu();
cout << "Enter Function: ";
getline(cin, Cmd);

if(Cmd == "Quit")
break;
else if(Cmd == "Fill")
Count = GetNames(List, Size);
else if(Cmd == "Show")
ShowNames(List, Count);
else if(Cmd == "Find") {
Result = FindName(List, Count);
cout << "Result = " << Result << endl;
}
else if(Cmd == "Delete") {
Result = DeleteName(List , Count);
cout << "Result = " << Result << endl;
}
}
}

void Menu()
{
cout << "Choices... " << endl;
cout << "------------------------" << endl;
cout << "Fill the list" << endl;
cout << "Show the entire List" << endl;
cout << "Find names on the list" << endl;
cout << "Delete names from the list" << endl;
cout << "Quit" << endl;
cout << "------------------------" << endl;

}

int GetNames(string List[], int MaxSize)
{
int K;
cout << "Enter Names Below, Stop To Quit." << endl;
for(K = 0 ; K < MaxSize ; K++) {
cout << "Enter Name: ";
getline(cin, List[K]);
if(List[K] == "Stop")
break;
}
Sort(List, K);
return K;
}

string FindName(string List[], int Size)
{
int K;
string LookingFor;

cout << "Enter Search Argument: ";
getline(cin, LookingFor);

for(K = 0 ; K < Size ; K++) {
if(LookingFor < List[K]) {
cout << "K = " << K << endl;
return "Name Not On The List";
}
if(LookingFor == List[K])
return List[K]; //Send back the name found...
}

return "Name Not Found"; //Only gets here if the name wasn't found...
}

string DeleteName(stri ng List[], int Size)
{
int K;
string RemoveCandidate ;

cout << "Enter Name To Be Deleted: ";
getline(cin, RemoveCandidate );

for(K = 0 ; K < Size ; K++)
if(RemoveCandid ate == List[K]) {
List[K] = "DELETED!!! ";
return RemoveCandidate + " Deleted";
}

return RemoveCandidate + " Not Found";
}
void ShowNames(strin g List[], int Size)
{
int K;

cout << "============== ============" << endl;
for(K = 0 ; K < Size ; K++)
cout << "List[" << K << "] = " << List[K] << endl;
cout << "============== ============" << endl;
}

void Sort(string List[], int Size)
{
int J, K;
string Hold;
bool DidSwap;

for(J = 0 ; J < Size ; J++) {
cout << "*";
DidSwap = false;
for( K = 0 ; K < Size-1 ; K++)
if(List[K] > List[K+1]) {
Hold = List[K];
List[K] = List[K+1];
List[K+1] = Hold;
DidSwap = true;
}
if( !DidSwap )
break;
}
cout << endl;
}


but i dont know how to combine them ... teacher wants that we should be able to

use those object on my first assignment..

Add Remove Find and View all Record objects.


please help me on this..thanks from now...
Dec 7 '06 #1
0 1060

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3277
by: Chris Mullins | last post by:
I've spent a bit of time over the last year trying to implement RFC 3454 (Preparation of Internationalized Strings, aka 'StringPrep'). This RFC is also a dependency for RFC 3491 (Internationalized Domain Names / IDNA) which is something that I also need to support. The problem that I've been struggling with in .NET is that of Unicode Code Points > 0xFFFF. These points are encoded into UTF8 using the Surrogate Pair encoding scheme that...
1
1250
by: William | last post by:
I have 2 VB.NET projects, each with multiple forms. I need to combine these 2 projects into 1 project that contains all the forms and methods of the 2. Is this possible? -- Regards, William
7
4822
by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following capital letters all work correctly - B C D F G M S T with the diacritical marker &#_0775. Why am I having a problem with P?
1
1402
by: pontifikas | last post by:
How difficult is it to have a project which contains portions of, say, C# and C++(or VB)? Can this be done? What are the general rules for doing such thing? *-----------------------* Posted at: www.GroupSrv.com *-----------------------*
0
1137
by: booksnore | last post by:
At the moment I have three separate setup projects for my C# ASP.NET application one for the web project, one that uses Custom actions and some code to create the database and then one which uses Custom Actions to prompt the user for username and pwd when installing a windows service. I want to bundle all three into a single install. I'm not sure if this possible with Visual Studio alone, if it is then does anyone know of a good online...
10
7498
by: John Salerno | last post by:
Is it possible to construct a C# form (using Visual Studio) but write only Python code for the events? Is there some way to tell your program to run Python whenever code is run, since it will be all Python code (e.g. for button presses, etc.)? I know it's sort of silly, and it makes your program depend on .NET, but it would be a nice and easy way to create a GUI while still writing in Python, if it's possible.
1
1635
by: kkjensen | last post by:
Hi there, I've got a problem that I'm sure is simple to someone with more experience. I have three tables: clients, tools and projects. Two of the fields in projects are linked to clients and tools (each project has a client and a tool). I would like one field in the "projects" table to be a combination of some of the info from all three tables. For example: client: bob (in the "client" table) tool: 25 (in the "tools" table)
5
5644
by: Tristan Miller | last post by:
Greetings. Is it possible using HTML and CSS to represent a combining diacritical mark in a different style from the letter it modifies? For example, say I want to render Å‘ (Latin small letter o with a double acute accent), but with the o in black and the double acute accent in green. Are either of the following valid? 1. <span style="color: black;">o</span><span style="color: green;">&#x030B;</span>
7
2745
by: MNNovice | last post by:
I have 3 queries that show expenses on various projects/funds. I would like to combine the results and show various expenses on each project/fund etc. But when I try to combine these 3 queries, the data gets repeated multiple times and the result becomes huge. Query 1: qryAPDetail has 92 records Query 2: qryPayDetail has 77 records Query 3: qryAllocDetail has 26 records How do I combine these queries to get a combined result...
0
1087
by: Anthony97 | last post by:
I got started in SQL server for less than 5 months and I am curious if anyone has ever combined multiple individual projects into one solution? If yes do you have any recommendations on accomplishing this? As always your suggestions are greatly appreciated.
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10624
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.