Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- class Windoge
- {
- public:
- Windoge() : m_size_x(0), m_size_y(0), m_title("New window")
- {
- }
- Windoge(unsigned int size_x, unsigned int size_y) : m_size_x(size_x), m_size_y(size_y)
- {
- }
- 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)
- {
- }
- void set_x(unsigned int new_x)
- {
- m_size_x = new_x;
- }
- void set_y(unsigned int new_y)
- {
- m_size_y = new_y;
- }
- void append_text(std::string line)
- {
- m_text.push_back(line);
- }
- void remline()
- {
- m_text.pop_back();
- }
- void set_title(std::string title)
- {
- m_title = title;
- }
- void display()
- {
- //Display the first line
- for(unsigned int i=0; i<m_size_x; ++i) std::cout<<'#'; std::cout<<std::endl;
- //Display the second line
- std::cout<<'#';
- for(unsigned int i=0; i<m_size_x-2; ++i) std::cout<<' ';
- std::cout<<'#'<<std::endl;
- //Display the third line
- std::cout<<"# ";
- std::cout<<m_title;
- for(unsigned int i=0; i<m_size_x-(4+m_title.size()); ++i) std::cout<<' ';
- std::cout<<" #"<<std::endl;
- //Display the fourth line
- std::cout<<'#';
- for(unsigned int i=0; i<m_size_x-2; ++i) std::cout<<' ';
- std::cout<<'#'<<std::endl;
- //Display the fifth line
- for(unsigned int i=0; i<m_size_x; ++i) std::cout<<'#'; std::cout<<std::endl;
- //Display the sixth line
- std::cout<<'#';
- for(unsigned int i=0; i<m_size_x-2; ++i) std::cout<<' ';
- std::cout<<'#'<<std::endl;
- //Now let's display the text
- for(unsigned int i=0; i<m_text.size(); ++i)
- {
- std::cout<<"# "<<m_text[i];
- for(int j=0; j<m_size_x-m_text[i].size()-3; ++j)
- std::cout<<' ';
- std::cout<<'#'<<std::endl;
- }
- //Display the blank lines
- for(int i=0; i<m_size_y-8-m_text.size(); ++i)
- {
- std::cout<<'#';
- for(unsigned int i=0; i<m_size_x-2; ++i) std::cout<<' ';
- std::cout<<'#'<<std::endl;
- }
- //Display the end line
- for(unsigned int i=0; i<m_size_x; ++i) std::cout<<'#'; std::cout<<std::endl;
- }
- private:
- unsigned int m_size_x, m_size_y;
- std::string m_title;
- std::vector<std::string> m_text; //Each line will be stored here
- };
- int main(int argc, char* argv[])
- {
- Windoge myWindow(60, 15, "Amazing window");
- myWindow.append_text("Much Program, Such Working.");
- myWindow.append_text("wow");
- myWindow.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement