Click here to Skip to main content
15,885,880 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to write a program that has a class called a console that keeps each object from this class information in its own. Each object created from the class by default has the black background color, the white color, the Hello World text! , The number of repetitions of text 1 and the total number of changes is 0.

And the user can determine the font color and background color. The user sets the color by entering the name of a color. I defined it by using the system ("color"), but I do not know how I can design the menu to set the colors and the user to select. Thank you for advising

What I have tried:

C++
#include "stdafx.h"
#include <iostream>
#include <string>
#include<conio.h>
using namespace std;

class console{
public:
	console( ) {
        string text = "Hello World!";
		system("Color 07");
		cout << text << endl;

	}//end of console constructor
};
//end of class

int main(){
	console obj1;

}
Posted
Updated 13-Jun-19 6:00am
v2
Comments
Rick York 12-Jun-19 10:51am    
If you do a search for console here you will find several articles that describe how to control the color of output to a console.

I don't think you want or need to call system to do that.

Usually on a textual (console) applications the menu is presented as a list of numbered alternatives. The user chooses a menu item by entering the corresponding integer.
 
Share this answer
 
v2
Comments
Member 14495966 12-Jun-19 9:17am    
Thanks
CPallini 12-Jun-19 9:21am    
You are welcome.
[no name] 18-Jun-19 8:13am    
this solutions works for me, thanks!
CPallini 18-Jun-19 8:22am    
You are welcome.
Use some loop for having a real program flow like in console menu and you can set text color.

In your code is the app exited after the first input.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900