fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <ctype.h>
  4. using namespace std;
  5.  
  6. class One {
  7. private:
  8. string * text;
  9. public:
  10. One();
  11. ~One();
  12.  
  13. void setText(string value);
  14.  
  15. string uppercase();
  16. string lowercase();
  17. string inverted();
  18. };
  19.  
  20. One::One() {
  21. text = new string();
  22. }
  23.  
  24. One::~One() {
  25. delete text;
  26. }
  27.  
  28. void One::setText(string value) {
  29. *text = value;
  30. }
  31.  
  32. string One::uppercase() {
  33. string result(*this->text);
  34.  
  35. for(int i=0; i<result.size(); i++) {
  36. char c = result[i];
  37. c = toupper(c);
  38. result[i] = c;
  39. }
  40.  
  41. return result;
  42. }
  43.  
  44. string One::lowercase() {
  45. string result(*this->text);
  46.  
  47. for(int i=0; i<result.size(); i++) {
  48. char c = result[i];
  49. c = tolower(c);
  50. result[i] = c;
  51. }
  52.  
  53. return result;
  54. }
  55.  
  56. string One::inverted() {
  57. string result;
  58.  
  59. string temp(*this->text);
  60. for(int i=temp.size()-1; i>=0; i--) {
  61. result = result + temp.at(i);
  62. }
  63.  
  64. return result;
  65. }
  66.  
  67. int main() {
  68. One one;
  69. one.setText("Kleber Mota de Oliveira");
  70. cout << "text:" << one.uppercase() << endl;
  71. cout << "text:" << one.lowercase() << endl;
  72. cout << "text:" << one.inverted() << endl;
  73. return 1;
  74. }
Runtime error #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
text:KLEBER MOTA DE OLIVEIRA
text:kleber mota de oliveira
text:arievilO ed atoM rebelK