lundi 8 octobre 2018

I have to create a digital grasshopper program for my homework which i have no idea about

Write a program that allows a user to issue a series of instructions to a digital grasshopper and reports on the grasshopper’s responses and status. Your program must model the following behaviors: 1. Train - creates a new digital grasshopper of the indicated. This will delete the previous digital grasshopper, so it should warn the user and ask them to commit before continuing. 2. Eat - the grasshopper attempts to eat the indicated . Should indicate whether it successfully ate the item or not. 3. Excrete – remove the oldest item the grasshopper has eaten from its stomach. Should indicate which item was excreted or if the stomach was empty. 4. Vomit – remove the newest item the grasshopper has eaten from its stomach. Should indicate which item was vomited or if the stomach was empty. 5. Report – list the contents of the grasshopper’s stomach, then output HUNGRY if the grasshopper’s stomach is empty or FULL if the grasshopper’s stomach is full

  1. Reset – should reset the grasshopper to its default settings (an empty stomach).
  2. Exit – terminates the program For this program, there are three kinds of digital grasshoppers that can be trained: crickets, hoppers, and locusts. The only difference between each kind of digital grasshopper is stomach capacity; crickets have a stomach capacity of 3, hoppers have a stomach capacity of 5, and locusts have a stomach capacity of 9. We will only feed the grasshopper grass, seeds, and bugs. Grass occupies 1 unit of space in the grasshopper’s stomach, seeds occupy 2 units, and bugs occupy 3 units. We will assume that the default digital grasshopper is a hopper.

Aucun commentaire:

Enregistrer un commentaire