Advertisement
pleasedontcode

**Inventory Management** rev_01

Nov 20th, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **Inventory Management**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-11-20 14:46:21
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* list = [ "gun", */
  21.     /* "health","wood","metal","brick","orb of death"] */
  22.     /* print("welcome to you own inventory manager.") */
  23.     /* thing = input("Would you like to add a item?") */
  24.     /* if thing == "no":       if thing == "yes": */
  25.     /* print ("these are the items you can add. */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28. /* START CODE */
  29.  
  30. /****** DEFINITION OF LIBRARIES *****/
  31. #include <Arduino.h>
  32. #include <String.h>
  33.  
  34. /****** FUNCTION PROTOTYPES *****/
  35. void setup(void);
  36. void loop(void);
  37.  
  38. // Define a list of items
  39. String itemList[] = {"gun", "health", "wood", "metal", "brick", "orb of death"};
  40. int itemCount = 6; // Updated to reflect the correct number of items
  41.  
  42. void setup(void)
  43. {
  44.     // put your setup code here, to run once:
  45.     Serial.begin(9600); // Start serial communication for input/output
  46.     Serial.println("Welcome to your own inventory manager.");
  47. }
  48.  
  49. void loop(void)
  50. {
  51.     // put your main code here, to run repeatedly:
  52.    
  53.     // Simulating user input for adding an item
  54.     Serial.println("Would you like to add an item? (yes/no)");
  55.     // In a real scenario, you would use Serial.readString() to get user input
  56.     String response = "yes"; // Simulated response for demonstration
  57.     if (response == "no") {
  58.         return; // Exit loop if user does not want to add an item
  59.     } else if (response == "yes") {
  60.         Serial.println("These are the items you can add:");
  61.         for (int x = 0; x < itemCount; x++) {
  62.             Serial.println(itemList[x]); // Print each item in the list
  63.         }
  64.        
  65.         // Simulating user input for adding an item
  66.         String newItem = "new_item"; // Simulated new item for demonstration
  67.         if (itemCount < 10) { // Check to prevent overflow
  68.             itemList[itemCount] = newItem; // Add new item
  69.             itemCount++; // Increment item count
  70.             Serial.print("Added item: ");
  71.             Serial.println(newItem);
  72.         } else {
  73.             Serial.println("Inventory full, cannot add more items.");
  74.         }
  75.     }
  76.  
  77.     // Print the entire list
  78.     Serial.println("Current list:");
  79.     for (int x = 0; x < itemCount; x++) {
  80.         Serial.print(itemList[x]);
  81.         if (x < itemCount - 1) Serial.print(", "); // Formatting for better readability
  82.     }
  83.     Serial.println();
  84.  
  85.     // Simulating user input for using an item
  86.     String usedItem = "orb of death"; // Simulated item for demonstration
  87.     Serial.print("Using item: ");
  88.     Serial.println(usedItem);
  89.    
  90.     // Check if the used item is "orb of death"
  91.     if (usedItem == "orb of death") {
  92.         Serial.println("You have died"); // Notify the user
  93.     }
  94. }
  95.  
  96. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement