Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I need help with my C++ program assignment, it's based on the book, C++ Programing 7th Edition . Background Abstraction is the performance of

Hello, I need help with my C++ program assignment, it's based on the book, C++ Programing 7th Edition.

Background

Abstraction is the performance of a task, or storage of data, by a sub-class in a manner that hides the details of what is being done from the parent class. In other words, the functions performed by methods and the data stored in members are abstracted when they are not directly accessible by the parent class and the exact nature of what they are or what they do is not public. Let me use the string class to illustrate. When you create an object of type string, you declare it much like a variable.

string szFirstName;

string is the class name and szFirstName is the object just created. This code creates the object by calling its constructor which, no doubt, does a whole bunch of things that we have no need to know about. When we set the "value" of szFirstName we are actually telling the class code to store the value in a character array that we do not have direct access to. The string class has methods that perform copying to and from its members when we use = to set and get the text. string also has methods that we can use to manipulate or get information about its members. For example, the .length() method will tell us how many characters a string object is holding. We cannot directly count those characters, they are hidden, but instead we call a method that tells us what we want to know. The beauty of abstraction is that you can place a whole lot of functionality into a class and move it out of the way - and include it in other programs when you need it. If you had to code all of the workings of the string class it would be hundreds of lines long. Instead, all you have to do is include the library and use the parts that you need. In this exercise you are going to roughly recreate the the MessageBox() method provided with Visual Basic.NET. You are going to add a class to existing code that will display a message, with emphasis and title text, in a box on the console. More information about abstraction is available in the Malik text in chapter 10 and the Dale text in chapter 12..

Procedure
1. Create a new Visual C++ Win32 Console application

Choose the default application settings

2. ***** Complete the project ***** Create a class named MessageClass with the following attributes:
A. A public method called MessageBox that accepts three parameters: String, integer, and string. Hint: Don't forget to include the three lines:

#include #include using namespace std;

in MessageClass.h just above the class definition.

B. Include 4 constants of type int in the header file that define Bonk, Question, Information and Wink so that main() can reference them in the call to MessageBox().
C. Create, initialize and use an array that holds the four emphasis characters, !, ?, i, and ; that align with the constants in Step B and the integer passed into the MessageBox() function.
D. In the code section of the MessageBox() method, create code that reproduces the following results: image text in transcribed Note that output to the console is performed from within the MessageBox() method. MessageBox() should be flexible enough to allow me to make changes to the strings in the call in the main() function and it will produce the similar, working results. Assume that the second string (the box header) will always be sufficiently smaller than the first string (box message).

Yes, there are easier ways to perform these tasks, but I want you to do it this way.

3. Insert your program documentation and code comments. Provide program documentation and comment both of the files generated with the new class.

-------------------------------------------------------------------------------------

Below is the code For my Main program entry.

-------------------------------------------------------------------------------------

#include "stdafx.h" #include #include #include "MessageClass.h";

using namespace std;

int _tmain(int argc, _TCHAR* argv[]) {

MessageClass msg;

msg.MessageBox("Welcome to My CIS class", msg.Bonk, "Hello");

cout

msg.MessageBox("Why did the chicken cross the road", msg.Question, "Why");

cout

msg.MessageBox("To get to the other side", msg.Information, "Because");

cout

msg.MessageBox("That is all", msg.Wink, "Thank you");

cout

-------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------

Below is my MessageClass.cpp

-------------------------------------------------------------------------------------

#include "stdafx.h" #include "MessageClass.h"

using namespace std;

void MessageClass::MessageBox(string, int, string) { }

MessageClass::MessageClass() { }

MessageClass::~MessageClass() { }

-------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------

Below is my MessageClass.h

-------------------------------------------------------------------------------------

#pragma once

#include #include

using namespace std;

class MessageClass { public:

void MessageBox(string, int, string); const int Bonk = '!'; const int Question = '?'; const int Information = 'i'; const int Wink = ';';

MessageClass(); ~MessageClass(); };

-------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------

Please help! I'm not sure what I'm doing. Fix and edit what is needed. Thank you very very much!

E 12016 Spring\022 OnlineAssignmentsl10ACIS022 S2016 Assignment10blDebugACIS022 S2016 A... O La LX Hello Welcome to CIS 022 from Mark Berrett Why Why did the chicken cross the road ii Because iiiiiiiiiiiiiiiii i To get to the other side i Thank you That is all Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago