Click here to Skip to main content
14,209,923 members
Rate this:
Please Sign up or sign in to vote.
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:

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

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

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

int main(){
	console obj1;

Updated 4 days ago
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.
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
Member 14495966 12-Jun-19 9:17am
CPallini 12-Jun-19 9:21am
You are welcome.
AlexGambler 2hrs 20mins ago
this solutions works for me, thanks!
CPallini 2hrs 15mins ago
You are welcome.
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.

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

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190617.3 | Last Updated 13 Jun 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100