Advertisement
patriciarae

???

Feb 26th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5. using namespace std;
  6.  
  7. class TripleString{
  8. private:
  9.    string string1;
  10.    string string2;
  11.    string string3;
  12.  
  13. public:
  14.    TripleString();
  15.    TripleString(string str1, string str2, string str3);
  16.    bool setString(string str1, string str2, string str3);
  17.    bool validString(string str1, string str2, string str3);
  18.    string getString();
  19.    static const int MIN_LEN = 1;
  20.    static const int MAX_LEN = 50;
  21. };
  22.  
  23. static const string DEFAULT_STRING = "(undefine)";
  24.  
  25. int main()
  26. {
  27.    TripleString kardashian, jenner, others, anotherOne;
  28.    string theString;
  29.  
  30.    kardashian.setString("kim", "khloe", "kourtney");
  31.    jenner.setString("kylie", "kendall", "kris");
  32.    others.setString("rob", "kanye", "caitlyn");
  33.    anotherOne.setString("", "", "");
  34.  
  35.    cout << theString << endl;
  36. }
  37.  
  38. TripleString::TripleString()
  39. {
  40.    string1 = DEFAULT_STRING;
  41.    string2 = DEFAULT_STRING;
  42.    string3 = DEFAULT_STRING;
  43. }
  44.  
  45. TripleString::TripleString(string str1, string str2, string str3)
  46. {
  47.    TripleString kardashian, jenner, others, anotherOne;
  48.    string theString;
  49.  
  50.    theString = kardashian.setString("kim", "khloe", "kourtney");
  51.    theString = jenner.setString("kylie", "kendall", "kris");
  52.    theString = others.setString("rob", "kanye", "caitlyn");
  53.    theString = anotherOne.setString("", "", "");
  54.  
  55.    if(str1.length() < MIN_LEN)
  56.       theString = DEFAULT_STRING;
  57.    else
  58.       theString = str1;
  59.    if(str2.length() < MIN_LEN)
  60.       theString = DEFAULT_STRING;
  61.    else
  62.       theString = str2;
  63.    if(str3.length() < MIN_LEN)
  64.       theString = DEFAULT_STRING;
  65.    else
  66.       theString = str3;
  67. }
  68.  
  69. bool TripleString::validString(string str1, string str2, string str3)
  70. {
  71.    string theString;
  72.  
  73.    if (str1.length() < MIN_LEN && str1.length() > MAX_LEN)
  74.       return false;
  75.    else
  76.       theString = str1;
  77.       theString = str1;
  78.       theString = str1;
  79.  
  80.    if (str2.length() < MIN_LEN && str2.length() > MAX_LEN)
  81.       return false;
  82.    else
  83.       theString = str2;
  84.       theString = str2;
  85.       theString = str2;
  86.  
  87.    if (str3.length() < MIN_LEN && str3.length() > MAX_LEN)
  88.       return false;
  89.    else
  90.       theString = str3;
  91.       theString = str3;
  92.       theString = str3;
  93.    return true;
  94. }
  95.  
  96. string TripleString::getString()
  97. {
  98.    return string1;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement