Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE A C++ CODE BUT MAKE SURE IT IS PLAGIARISM FREE A Banner can be created/instantiated (when a variable is declared in main( ) or
PLEASE A C++ CODE BUT MAKE SURE IT IS PLAGIARISM FREE
A Banner can be created/instantiated (when a variable is declared in main( ) or some other function), in one of 2 ways: PART 1: Without accepting ANY parameters, a Banner object would store the string: "Whom the Gods would destroy they first make mad!" and set its index to to indicate where to begin displaying the string. This is the default constructor. PART 2: By accepting 2 parameters: a constant string 'sParam' and an integer ' n '. If created in this way, only up to the first 70 characters of the string 'sParam' are copied into the Banner's string 's' and its starting index would be set to ' n ' but only if ' n ' is within the range 0 to 69 inclusive. If ' n ' is outside that range, then the Banner's starting index is set to 0. So for example, if the string 'sParam' was: "Hello World!", and 'n' was 6, then the Banner object would store the string: 012345678901 "Hello World!" and would begin displaying the string starting at index 6 +-- begin displaying the string here A Banner object also contains the following other public: member functions: PART 3: int setIndex (int newIndex) This function changes the Banner's index to 'newIndex' but only if it is in the range of 0 to 1 less than the length of the current Banner's string inclusive. If 'newIndex' is outside this range, then the Banner's index is not changed. The function returns 1 if the index was changed or 0 otherwise. For example, if the Banner's string is: "Hello" (5 characters) and newIndex is: 20, then the index is NOT changed and a return value of is sent back. For example, if the Banner's string is: "Hello" (5 characters) and newIndex is: 4, then the index Is changed and a return value of 1 is sent back. PART 4: int setstring(const char *s1) This function replaces the Banner's string with 's1' and updates its index to 0 , but only if the length of 's1' is less than or equal to 70. If 's1' is longer than 70 characters, then it is not copied over and the object's index is not changed. This function returns 1 if the Banner's string was changed or 0 otherwise. PART 5: int addToBanner (const char *s2) This function ADDS to the Banner's string as many characters from 's2' as the Banner's string can hold without exceeding 70 characters. For example if the Banner's string is currently: "Where do you want" and 's2' is: "to go Today?", then the Banner's string becomes: "Where do you want to go Today?". This function does NOT update the index. The function returns 1 if the Banner was changed or 0 otherwise. NOTE: Be very careful with your solution to this function! As long as the Banner's string is less than 70 characters, then it will accept additional characters from ' s2,butnotanymore than 70 total! PART 6: const char* getstring( ) This function simply returns the address of the string being stored in the Banner object offset by the value in its index. So that, if the string is: "Hello World!" and the index is: 4, then the return value would be the address +4 (which would display: "o World!" if output using printf( )). // Correct Program OUTPUT is: c1: Whom the Gods would destroy they first make c2: The streets Have No Name by: U2 c3: bc Whom the Gods would destroy they first make mad! hom the Gods would destroy they first make mad! om the Gods would destroy they first make mad! the Gods would destroy they first make mad! the Gods would destroy they first make mad! the Gods would destroy they first make mad! he Gods would destroy they first make mad! e Gods would destroy they first make mad! Gods would destroy they first make mad! Gods would destroy they first make mad! ods would destroy they first make mad! ds would destroy they first make mad! s would destroy they first make mad! would destroy they first make mad! would destroy they first make mad! ould destroy they first make mad! uld destroy they first make mad! ld destroy they first make mad! d destroy they first make mad! destroy they first make mad! destroy they first make mad! estroy they first make mad! stroy they first make mad! troy they first make mad! roy they first make mad! oy they first make mad! they first make mad! they first make mad! they first make mad! hey first make mad! ey first make mad! y first make mad! first make mad! first make mad! irst make mad! rst make mad! st make mad! t make mad! make mad! make mad! ake mad! ke mad! e madStep 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