Instructions:
YOU WILL SUBMIT MULTIPLE FILES FOR THIS PROGRAMMING PROJECT. Create a sub-directory named ”hw2” in your cs410 directory. Use that subdirectory for all your file submissions on this assignment. At the end of the homework assignment, as a minimum, these files should be found in your hw2 directory:
1. hw2 functions.cpp (function definitions)
2. hw2 functions.h (function declarations)
3. hw2.cpp (main)
4. a “typescript” file demonstating program compilation, execution and testing
You may include other source/header files if you please.
Background: After weeks of stress, Krusty is taking a vacation to Atlantis. But now, the Atlantians (those weirdos living in Atlantis) have made it so that he can’t leave to go back home unless he jumps through the right hoops. Those ”hoops” are that he first visits with enough of the inhabitants (weirdos) to satisfy the Atlantis Visitors’ Bureau. And to prove that he has done so, he has to collect the business cards of each one he visits and show the ”gatekeepers” as he leaves. There’s just one problem ...... Krusty is his own worst enemy in that he has a business card fetish: he won’t carry multiple cards in his hands unless he can stack them so that no card is smaller than the card below it1. Now, he can orient the stacked cards any way he wants, but a card can’t ”hangover” (or be the same size as) the card above it. This is stupid, but oh well! It’s part of the reason why Krusty is an interesting character. Fortunately for Krusty, there’s an out: IF he visits enough different inhabitants, he can get out of Atlantis regardless of how the cards are stacked.
Specifications: Your program is to simulate this situation. Krusty will visit at random some of the various ”creatures” (inhabitants) of Atlantis, whereupon each of the creatures will say something chosen at random from a list of comments (below), and then give him their card which he will put in his pocket. Each creature has a card specific to them. What is important about their card is its dimensions: length and width (assume these are integers). Each time he gets a card, he needs to assess whether or not he can leave Atlantis (like really! No good hay-bars...only sushi restaurants.) When he confirms he has satisfied the Rules of Leavature, he needs to output an exclamation that he is leaving (we’ll leave the wording up to you - make it clean) and returning home, and state with detail what gives him the right to leave. Leavature Rules are specified below. And what details are we expecting? Either output the names of the creatures’ cards and their dimension of the 6 stackable cards1, or output the 14 different names of the 14 different creatures he got cards from.
Example: card1 is 4 × 8, card2 is 2 × 9. These can NOT satisfy Krusty’s criteria since there is no way to orient (at right angles) these two cards without one hanging over the other. As another example: card1 is 2 × 3 and card2 is 1 × 2. These two CAN satisfy Krusty’s criteria since card2 can be stacked below card1 in a way that it will not hang over the top card since 1 < 2 and 2 < 3. So, you see, you must compare the cards in both orientations. Both dimensions of a lower card must not exceed either dimensions of an upper card, and at least one dimension of an upper card must be strictly greater than at least one dimension of a lower card. (Another example: a 1 × 1 card can be below a 1 × 2 card)
Details:
1. You are expected to use a structure for a creature that includes its name and the dimensions of its card.
2. You are expected to use vectors in this assignment as appropriate. For example, you could set up a const string vectors loaded with the sayings that the creatures can speak. Think about how you could randomly choose an entry from that vectors.
3. You can assume that our hero Krusty will collect no more than 150 cards. (Hmmmm, is that another hint about an appropriate use of vectors???)
4. Leavature Rules (a.k.a. Rules of Leavature): Krusty can leave if he has 6 (six) ”stackable” cards (like, you know, non-overlapping); OR he has cards from 14 different creatures (implies 11 tunas’ cards and 3 sardines’ cards ain’t gonna do it!). And then you need to use Template in C++ to output the result. Templates allow you to define actions for a class or function, and let you specify the concrete types these actions should handle
(For example, the output should be 6 cards with its sizes and print out by ordered, Or the output should have 14 different creatures and print it out)
5. In your code, generate a random creature before you generate a random saying.
6. If you end up stacking cards that you had repeats of (e.g. you stack a 2 × 3 and you got two of these cards from two different creatures), we care not which creature’s card you use.
7. Each creature has many cards. So, each time it is visited, it can hand a card to Krusty.
8. The data to use can be found in “creatures.txt” file in the homework directory (creature and their card specs).
9. A list of the things a creature can say can be found in the “sayings.txt” file in the Discord homework channel.
Special Underwater Observation: You will find your coding easier if you were to sort your cards when gathering them. Think carefully how this has to be done. You wouldn’t want to overload your day with an overload of work when overloading your brain while coding...