Question: Your job now is to edit this program, which has a function inside of it that is a stub. That function does NOT produce the

 Your job now is to edit this program, which has afunction inside of it that is a stub. That function does NOT

Your job now is to edit this program, which has a function inside of it that is a stub. That function does NOT produce the correct outputit always just returns the string stub.

Suppose we want your program to draw a T with width 3 and height 2, we will run your starT executable as follows: $./starT 3 2

In general the parameters to the startT program are width, followed by height. You should take this into consideration when writing your main function. To write the starT() function refer back to the description of starT earlier in this lab. You can also run the program with arguments of -1 -1 to run the internal tests and see whether your implementation is correct.

Some rules to keep in mind for the starT function:

- EVERY line of your T should have exactly the same number of characters and should end in a newlineremember to pad out each line with spaces.

- Return a string that represents the letter T with the correct width and height, but only if height >=2, and width is an odd number >=3

- if the height and width values are not valid, return an empty string

Also:

- If there are not exactly two command line args after the program name (one for width and one for height), print a usage message:

Usage: ./starT width height 

- If the height and width are both -1, then invoke the internal tests. Dont change those. If you do, then you may lose points.

5 #include #include using namespace std 10 void assertEquals(string expected, string actual, string message) 11 string starT(int width, int height); 12 void runTests(void) 14 Write starT per specifictions in the lab writeup 15 Iso that internal tests pass, and submit.cs system tests pass 16 17 string starT(int width, int height) 18 19 string result=""; 20 result = "stub". // TODO: remove this line, replace with correct code return result; 23 24 I Test-Driven Development; check expected results against actual 25 26 void runTests (void) 27 28 I1/ The following line works because in C and C++ when string literals 9 are separated only by whitespace (space, tab, newline), they 30 1/ automatically get concatenated into a single string literal 31 32 string starT34Expected= 35 36 38 assertEquals(starT34Expected,starT(3,4), "starT(3,4" 39 40 string starT53Expected 41 n" In" 45 assertEquals(starTS3Expected, starT(5,3), "starT(5,3)" 47 string starT72Expected I"n" 50 51 assertEquals(starT72Expected, starT(7,2), "starT (7,2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!