Question
Objective Write a program that does the following to simulate a bag of candy: 1. At start up, the program creates an instance of type
Objective Write a program that does the following to simulate a bag of candy: 1. At start up, the program creates an instance of type Candies called bag. It is constructed to contain 21 purple candies, 22 yellow candies, 23 green candies, and 24 red candies. 2. It then calls the Candies member function CountCandies on bag. 3. The amount of candies returned by CountCandies is displayed to the terminal. See Expected Output for details. You may not use notes or other sources of information, but you may use the compiler to check your work. Turn in your completed .cpp file to TITANium to receive credit. Requirements Your program must have the following attributes: 1. It must define a class named Candies that contains four private integer data members. The four members are named: purple, yellow, green, and red. 2. Your program must define and call a public member function called CountCandies. It takes no parameters and returns an integer that is the sum of all of its data members. (purple+yellow+green+red) 3. The class must include a public constructor that takes in four integer parameters, one for each type of candy. The parameter values are assigned to the corresponding class data members 4. All code should adhere to good coding style guidelines. Expected Output Total: 90
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started