Pig_Latin

// Good Morning I need help for this my project...
// I didn't understand yet..

// main
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <conio.h>
#include <iomanip>
#include <string>
#include "piglatin.h"
using namespace std;

int main() {
char ans;
string st;
cout << "\n\t\t **********************************" << endl;
cout << "\t\t * ------------------------------ *" << endl;
cout << "\t\t * MP2 - Pig Latin *" << endl;
cout << "\t\t * ------------------------------ *" << endl;
cout << "\t\t **********************************" << endl << endl;
cout << "\t\t -----------------------------------" << endl;

do {

cout << "\n\t\tEnter string: ";
cin >> st;
pigLatin s;

for(int i=0; i<st.length();i++)
s.insertLast(st.at(i));
cout << endl;
s.relpace();
cout << "\n\n\t\tTry Again? [Y/N]: ";
cin >> ans;
cout << endl << endl;
}while (ans=='Y'||ans=='y');
system("cls");

getch();
cin.get();
cin.get();
return 0;
}

//header file

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

struct Node {
char info;
Node *link;
};

class pigLatin {
public:
pigLatin();
void removeFront();
void insertLast(char);
bool isVowel(char);
bool noVowel();
void rotate();
void relpace();
void out();
private:
Node *first;
Node *last;
int count;

};

void pigLatin::removeFront(){
if(first!=NULL){
Node * p = first;
first = first->link;
delete p;
p = NULL;
--count;
}
}
void pigLatin::insertLast(char a) {
Node * newNode = new Node;
newNode->info = a;
newNode->link = NULL;

if(first==NULL) {
first = newNode;
last = newNode;
count++;

} else {
last->link = newNode;
last = newNode;
count++;
}

}
pigLatin::pigLatin() {
first = NULL;
last = NULL;
count = 0;
}

bool pigLatin::isVowel(char str) {
if(str=='a' || str=='e' || str=='i' || str=='o' ||
str=='u' ||
str=='A' ||
str=='E' ||
str=='I' ||
str=='O' ||
str=='U' ||
str=='y' ||
str=='Y')
return true;
else
return false;
}

void pigLatin::relpace() {

if(isVowel(first->info)){
cout << "\t\tPigLatin Equivalent: ";
out();
cout << "-way";
}
else if (noVowel()){
cout << "\t\tPigLatin Equivalent: ";
out();
cout << "-way";

}
else {
insertLast('-');
while(!isVowel(first->info))
rotate();
cout << "\t\tPigLatin Equivalent: ";
out();
cout << "ay";
}
}

void pigLatin::rotate() {
insertLast(first->info);
removeFront();
}

void pigLatin::out() {
Node * current = first;
while(current != NULL) {
cout << current->info;
current = current->link;
}
}


bool pigLatin::noVowel() {
int c = 0;
Node * current2 = first;
while(current2!=NULL){
if(current2->info=='a'||current2->info=='e'||current2->info=='i'||current2->info=='o'||
current2->info=='u'||
current2->info=='A'||
current2->info=='E'||
current2->info=='I'||
current2->info=='O'||
current2->info=='U'||
current2->info=='Y'||
current2->info=='y')
c++;
current2 = current2->link;
}
return (c==0);
}

Please use code tags: [code]Your code[/code]
Read this: http://www.cplusplus.com/articles/z13hAqkS/

Any questions?
Topic archived. No new replies allowed.