Advertisement
KingAesthetic

C++ Exmaple 3

Aug 12th, 2024
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. // define the kind of structure for the puzzle piece.
  6. struct PuzzlePiece {
  7.     int id;
  8.     char shape[20];
  9. };
  10.  
  11. // define the enum for achievements.
  12. enum Achievement {
  13.     ACHIEVEMENT_LEVEL1,
  14.     ACHIEVEMENT_LEVEL2,
  15.     ACHIEVEMENT_LEVEL3
  16. };
  17.  
  18. // function for solving a puzzle piece.
  19. void solvePuzzlePiece(PuzzlePiece piece, bool isConnected) {
  20.     std::cout << "Solving piece " << piece.id << " with shape: " << piece.shape << std::endl;
  21.  
  22.     if (isConnected) {
  23.         std::cout << "Piece " << piece.id << " is connected to the puzzle!" << std::endl;
  24.     } else {
  25.         std::cout << "Piece " << piece.id << " is not connected yet." << std::endl;
  26.     }
  27. }
  28.  
  29. // function for tracking achievements.
  30. void trackAchievement(Achievement achievement) {
  31.     switch (achievement) {
  32.         case ACHIEVEMENT_LEVEL1:
  33.             std::cout << "Unlocked Level 1 achievement!" << std::endl;
  34.             break;
  35.         case ACHIEVEMENT_LEVEL2:
  36.             std::cout << "Unlocked Level 2 achievement!" << std::endl;
  37.             break;
  38.         case ACHIEVEMENT_LEVEL3:
  39.             std::cout << "Unlocked Level 3 achievement!" << std::endl;
  40.             break;
  41.         default:
  42.             std::cout << "Unknown achievement!" << std::endl;
  43.     }
  44. }
  45.  
  46. // function to unlock an achievement.
  47. void unlockAchievement(const char* achievementName) {
  48. }
  49.  
  50. // function for rolling a dice.
  51. int rollDice() {
  52.     srand(time(nullptr)); // seeding a random number generator.
  53.     return rand() % 6 + 1; // roll a 6-sided dice
  54. }
  55.  
  56. // Bible verses (KJV)
  57. const char* bibleVerses[] = {
  58.     "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. - John 3:16",
  59.     "The Lord is my shepherd; I shall not want. - Psalm 23:1",
  60.     "In the Beginning was the Word, and the Word was with God, and the Word was God. - John 1:1"
  61. };
  62.  
  63. // function that generates a random Bible Verse.
  64. const char* getRandomBibleVerse() {
  65.     srand(time(nullptr)); // seeding the random number generator.
  66.     int numVerses = sizeof(bibleVerses) / sizeof(bibleVerses[0]);
  67.     int randomIndex = rand() % numVerses;
  68.     return bibleVerses[randomIndex];
  69. }
  70.  
  71. int main() {
  72.     PuzzlePiece piece1 = {1, "Corner"};
  73.     solvePuzzlePiece(piece1, true);
  74.     trackAchievement(ACHIEVEMENT_LEVEL2);
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement