diff --git a/3-conditionals-and-logic/magic-8-ball/magic8_switch.cpp b/3-conditionals-and-logic/magic-8-ball/magic8_switch.cpp index 9fd13dc..9a79c46 100644 --- a/3-conditionals-and-logic/magic-8-ball/magic8_switch.cpp +++ b/3-conditionals-and-logic/magic-8-ball/magic8_switch.cpp @@ -1,51 +1,74 @@ +/* +C++ Program codecademy, magic8 balls, random fortune game +description : +1. random fortune game each time from 0 - 9 +2. every declare a random number can print this output : + 1) It is certain. + 2) It is decidedly so. + 3) Without a doubt. + 4) Yes - definitely. + 5) You may rely on it. + 7) Ass I see it, yes. + 8) Most likely. + 9) Outlook good. +3. This program make an switch case concepts to make conditional +*/ #include +#include #include -int main() { - - std::cout << "MAGIC 🎱 SAYS: \n\n"; - - srand(time(NULL)); - - int choice = std::rand() % 10; - - switch(choice) { - case 0: - std::cout << "No. Not really.\n"; - break; - case 1: - std::cout << "Val!\n"; - break; - case 2: - std::cout << "You are an adult.\n"; - break; - case 3: - std::cout << "Four R's, my friend: Reduce, reuse, recycle, Rihanna.\n"; - break; - case 4: - std::cout << "Nomo FOMO.\n"; - break; - case 5: - std::cout << "Yas.\n"; - break; - case 6: - std::cout << "Work it, dawg!\n"; - break; - case 7: - std::cout << "Carpe dayum!\n"; - break; - case 8: - std::cout << "Cha-Chinga!\n"; - break; - case 9: - std::cout << "Yaaaaas Kween!\n"; - break; - default: - std::cout << "IDK.\n"; - break; - - } - - return 0; +int main (){ + std::cout << "================================\n"; + std::cout << "Welcome to program fortune game \n"; + std::cout << "Magic 8-BALL : \n"; + srand(time(NULL)); + int answer_number = std::rand() % 10; + std::string answer; + + // Make conditional to print base of case answer_number + switch (answer_number){ + case 1 : + answer = "It is certain."; + break; + + case 2 : + answer = "It is decidedly so."; + break; + + case 3 : + answer = "Without a doubt."; + break; + + case 4 : + answer = "Yes - definitely."; + break; + + case 5 : + answer = "You may rely on it."; + break; + + case 6 : + answer = "As I see it, yes."; + break; + + case 7 : + answer = "Most likely."; + break; + + case 8 : + answer = "Outlook good."; + break; + + case 9 : + answer = "Yes."; + break; + + default : + answer = "Invalid fortune number."; + break; + } + std::cout << answer << "\n"; + std::cout << "================================\n"; + return 0; }