1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#include <iostream>
#include <fstream>
using namespace std;
struct NodeType
{
long Id_Num;
string Name;
string Phone;
char Status;
float Income;
NodeType* next;
};
/////////////////////////////////////
class linklist
{
private:
NodeType* first;
void searchList();
public:
linklist()
{first = NULL;}
void Input(long Id, string N, string P, char S, float In);
void addMember(long Id, string N, string P, char S, float In);
void removeMember();
void displayMember();
void displayAll();
};
////////////////////////////////////////
void linklist::Input(long Id, string N, string P, char S, float In) //input file
{
NodeType* nextlink = new NodeType;
nextlink->Id_Num = Id;
nextlink->Name = N;
nextlink->Phone = P;
nextlink->Status = S;
nextlink->Income = In;
nextlink->next=first;
first = nextlink;
ifstream infile("Member.txt");
infile >> Id >> N >> P >> S >> In;
}
void linklist::addMember(long Id, string N, string P, char S, float In)
{
cout << "New member ID: "; cin >> Id;
cout << "New member name: "; cin >> N;
cout << "New member phone number: "; >> P;
cout << "New member status: "; >> S;
cout << "New member income: "; >> In;
NodeType* newlink = new NodeType;
newlink->Id_Num = Id;
newlink->Name = N;
newlink->Phone = P;
newlink->Status = S;
newlink->Income = In;
newlink->next = first;
first = newlink;
}
////////////////////////////////////////
void linklist::displayAll()
{
NodeType* current = first;
while(current != NULL)
{
cout <<current->Id_Num;
cout << current->Name;
cout << current->Phone;
cout << current->Status;
cout << current->Income;
current = current-> next;
}
}
////////////////////////////////////////
int main()
{
void addMember(long Id, string N, string P, char S, float In);
cout << "This program allows the user to add or remove members from a club register.\n"
<<"The user may also display individual members or the entire list.\n\n";
linklist li;
char ch;
//li.Input(long Id, string N, string P, char S, float In);
//Main menu:
do{
cout<<"\n\n1. Add a member\n2. Remove a member \n3. Display a member \n4. Display all members \n5. Quit";
cout<<"\nEnter your choice:\t";
cin>>ch; //Stores menu choice
}while(ch != 5);
if(ch == 1)
{
}
else if (ch == 2)
{
}
else if (ch == 3)
{
}
else if (ch == 4)
{
li.displayAll();
}
return 0;
}
|