Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. class Windoge
  6. {
  7.     public:
  8.         Windoge() : m_size_x(0), m_size_y(0), m_title("New window")
  9.         {
  10.         }
  11.  
  12.         Windoge(unsigned int size_x, unsigned int size_y) : m_size_x(size_x), m_size_y(size_y)
  13.         {
  14.         }
  15.  
  16.         Windoge(unsigned int size_x, unsigned int size_y, std::string title) : m_size_x(size_x), m_size_y(size_y), m_title(title)
  17.         {
  18.         }
  19.  
  20.         void set_x(unsigned int new_x)
  21.         {
  22.             m_size_x = new_x;
  23.         }
  24.  
  25.         void set_y(unsigned int new_y)
  26.         {
  27.             m_size_y = new_y;
  28.         }
  29.  
  30.         void append_text(std::string line)
  31.         {
  32.             m_text.push_back(line);
  33.         }
  34.  
  35.         void remline()
  36.         {
  37.             m_text.pop_back();
  38.         }
  39.  
  40.         void set_title(std::string title)
  41.         {
  42.             m_title = title;
  43.         }
  44.  
  45.         void display()
  46.         {
  47.             //Display the first line
  48.             for(unsigned int i=0; i<m_size_x; ++i) std::cout<<'#'; std::cout<<std::endl;
  49.  
  50.             //Display the second line
  51.             std::cout<<'#';
  52.             for(unsigned int i=0; i<m_size_x-2; ++i) std::cout<<' ';
  53.             std::cout<<'#'<<std::endl;
  54.  
  55.             //Display the third line
  56.             std::cout<<"# ";
  57.             std::cout<<m_title;
  58.             for(unsigned int i=0; i<m_size_x-(4+m_title.size()); ++i) std::cout<<' ';
  59.             std::cout<<" #"<<std::endl;
  60.  
  61.             //Display the fourth line
  62.             std::cout<<'#';
  63.             for(unsigned int i=0; i<m_size_x-2; ++i) std::cout<<' ';
  64.             std::cout<<'#'<<std::endl;
  65.  
  66.             //Display the fifth line
  67.             for(unsigned int i=0; i<m_size_x; ++i) std::cout<<'#'; std::cout<<std::endl;
  68.  
  69.             //Display the sixth line
  70.             std::cout<<'#';
  71.             for(unsigned int i=0; i<m_size_x-2; ++i) std::cout<<' ';
  72.             std::cout<<'#'<<std::endl;
  73.  
  74.             //Now let's display the text
  75.             for(unsigned int i=0; i<m_text.size(); ++i)
  76.             {
  77.                 std::cout<<"# "<<m_text[i];
  78.                 for(int j=0; j<m_size_x-m_text[i].size()-3; ++j)
  79.                     std::cout<<' ';
  80.                 std::cout<<'#'<<std::endl;
  81.             }
  82.  
  83.             //Display the blank lines
  84.             for(int i=0; i<m_size_y-8-m_text.size(); ++i)
  85.             {
  86.                 std::cout<<'#';
  87.                 for(unsigned int i=0; i<m_size_x-2; ++i) std::cout<<' ';
  88.                 std::cout<<'#'<<std::endl;
  89.             }
  90.  
  91.             //Display the end line
  92.             for(unsigned int i=0; i<m_size_x; ++i) std::cout<<'#'; std::cout<<std::endl;
  93.  
  94.         }
  95.  
  96.     private:
  97.         unsigned int m_size_x, m_size_y;
  98.         std::string m_title;
  99.         std::vector<std::string> m_text;    //Each line will be stored here
  100. };
  101.  
  102. int main(int argc, char* argv[])
  103. {
  104.     Windoge myWindow(60, 15, "Amazing window");
  105.     myWindow.append_text("Much Program, Such Working.");
  106.     myWindow.append_text("wow");
  107.     myWindow.display();
  108.     return 0;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement