Question
Be sure that only the file you want to submit is in that directory - make a directory for every assignment! Remember that the submit
Be sure that only the file you want to submit is in that directory - make a directory for every assignment! Remember that the submit system will deliver every .cpp file in the current directory to me, so you should only have the file for hw 5 in that directory. Name your file a meaningful name and give it a .cpp extension since you will be compiling it. Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work for the submit script. Background: BoJack currently works in a computer science department at a major university on Atlantis. The front office of this department is quite unique. There are two staff there to help you, and a gaggle of lounge-lizards who hangout in the office mostly because: 1) it's a good place to hide from faculty; and 2) there are free chips and comfy couches. Curiously, they're all named Dylan. Some spell it differently, but ... hey, it's still Dillon. He wants to have a program that will emulate the (anti)social interaction of any unsuspecting soul who enters the office. They are greeted by Rachel, heckled by the Dylans, and finally get attention from Elaina. Your program will have Rachel issue a pleasant greeting and hand you a card upon which you will accumulate points, have you randomly interact with the Dylans whereupon you will accumulate (or not) those points, and finally, given that you have gained the requisite pointage (not a word), which is 30 points in today's political climate, you get to interact with Elaina who makes sure you know where the exit is. Nice? eh? (This could be a government agency!) Specifications: For this assignment, you are going to write functions and have them implement the flow of control. Below, I'll describe the individual functions and what they will do and return. In general, the simulation will proceed as follows:
start main
declare int card, and any other vars needed
beginSimulation()
card = rachel()
loop until card accumulates enough points
get random num in [1, 5]
switch on that num
call appropriate dylan() for dylan-output and update of card
end loop
call elaina()
call leave()
end main function
Here are the descriptions of the functions you are to use:
The beginSimulation() function will simply output a message to the person running this program explain very briefly that it simulates the operation of the front office ... You pass it nothing and it returns nothing.
The rachel() function will output a very pleasant greeting (and warning about the Dylans), and return an integer. The integer returned represents the number on your "card" you will start with. That number will be randomly generated in this function and should be between 0 and 4, inclusive.
The Dylan functions will all return an integer representing the number of chips you will receive when you "visit and talk with" a Dylan, and each will alter the number of points on your card, that you must pass to the function. Here are their specs:
dylan1() will give you 5 chips; add 7 points to your card; and output "Hey. Are you ok? Here, have some chips...they're free."
dylan2() will give you 10 chips; double your card pointage (not a word); and output "Ignore him. Chips?! What kind?"
dylan3() will only give you 3 chips1; will add 8 points to your card; and will output "Hull LO".
dylan4() will just snore at you, outputting "ZZzzzzzzzz"; won't give you any chips because has none because the other dylans stole his while he was sleeping on the couch; will wake long enough to take 2 points away from your card.
dylan5() will give you 4 chips; output "You won't do it; your're scared."; and will double your points if your point count is under 10, and will add 5 points if your point count is 10 or over.
The elaina() function is the friendliest function of the bunch. Elaina is that way. This function will be passed an int (your "card") proving that you have earned the right to see Elaina (earned at least 30 points), where upon the function will
output "Only xxx points? Please leave through that door. Here's a dum-dum for your efforts." if you have no more than 40 points. (Of course, "xxx" refers to the number of points on their "card".)
output "Wow, you have xxx points. You get a smarty. Please leave through that door." if you have 41 to 60 points.
output "Double WOW, you have xxx points. Here's 2 smarties. You get to talk with the boss." if you have more than 60 points.
The leave() function simply outputs a message stating how many points and chips the user leaves with, and message stating that the simulation is done.
Details: In order to generate random numbers, you will have to use the system's random number generator. We will cover this topic in class on Friday. You will need to #include in any program using the RNG. As you develop your program, to get "real randomnesses", seed the rng with time(NULL). In class we'll show you what this means. But when you submit, we'll specify a particular seed so that everyone gets the same results.
When you submit: seed the random number generator in your code with 111.
As always, if you have questions, be sure to ask.
1This Dylan likes chips too much to share too much.
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