Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- class TripleString{
- private:
- string string1;
- string string2;
- string string3;
- public:
- TripleString();
- TripleString(string str1, string str2, string str3);
- bool setString(string str1, string str2, string str3);
- bool validString(string str1, string str2, string str3);
- string getString();
- static const int MIN_LEN = 1;
- static const int MAX_LEN = 50;
- };
- static const string DEFAULT_STRING = "(undefine)";
- int main()
- {
- TripleString kardashian, jenner, others, anotherOne;
- string theString;
- kardashian.setString("kim", "khloe", "kourtney");
- jenner.setString("kylie", "kendall", "kris");
- others.setString("rob", "kanye", "caitlyn");
- anotherOne.setString("", "", "");
- cout << theString << endl;
- }
- TripleString::TripleString()
- {
- string1 = DEFAULT_STRING;
- string2 = DEFAULT_STRING;
- string3 = DEFAULT_STRING;
- }
- TripleString::TripleString(string str1, string str2, string str3)
- {
- TripleString kardashian, jenner, others, anotherOne;
- string theString;
- theString = kardashian.setString("kim", "khloe", "kourtney");
- theString = jenner.setString("kylie", "kendall", "kris");
- theString = others.setString("rob", "kanye", "caitlyn");
- theString = anotherOne.setString("", "", "");
- if(str1.length() < MIN_LEN)
- theString = DEFAULT_STRING;
- else
- theString = str1;
- if(str2.length() < MIN_LEN)
- theString = DEFAULT_STRING;
- else
- theString = str2;
- if(str3.length() < MIN_LEN)
- theString = DEFAULT_STRING;
- else
- theString = str3;
- }
- bool TripleString::validString(string str1, string str2, string str3)
- {
- string theString;
- if (str1.length() < MIN_LEN && str1.length() > MAX_LEN)
- return false;
- else
- theString = str1;
- theString = str1;
- theString = str1;
- if (str2.length() < MIN_LEN && str2.length() > MAX_LEN)
- return false;
- else
- theString = str2;
- theString = str2;
- theString = str2;
- if (str3.length() < MIN_LEN && str3.length() > MAX_LEN)
- return false;
- else
- theString = str3;
- theString = str3;
- theString = str3;
- return true;
- }
- string TripleString::getString()
- {
- return string1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement