Adopt-A-Pet
You are writing the code for an app for a virtual Pet.
First the person gets to name the pet. This will be the only input at this time.
Each pet starts with an initial energy level of 100. Energy is always a whole number.
- Every 10 minutes of sleep adds 2 to the energy level. No energy is added for partial sleeping blocks. For example, if the pet slept for 14 minutes, add 2 to the energy level. The additional 4 minutes do not count towards increasing the energy level.
- Every 5 minutes of exercise subtracts 7 from the energy level. No energy is subtracted for partial exercise sessions. For exmaple, if the pet exercised for 11 minutes, only subtract 14 (2 sets of 5 minutes) from the energy level. The additional 1 minute of exercise does not decrease the pets energy.
- Each eaten meal adds 5 to the energy level of the pet.
You will provide the number of meals eaten, minutes of sleep, and exercise minutes for the pet as assignments to these variables, rather than input.
The program will announce the energy level of the pet in the following format:
Rusty has an energy level of 90
Step 1: Create a plan
Use the following questions as a guide to help you write your program.
Variables
- Identify the variables you will need for this program.
- What data types will you need for each variable?
- What is the initial data for each variable?
|
An AI Minute, Let's Use AI! |
| Be sure to tell AI that you do not want it to provide you with any code at this time. Give AI the initial prompt and provide it with the varialbes you have identified. Ask AI if it thinks you need any additional variables and why. Here's a sample prompt: Do not provide any program code at this time. I have been asked to write the following program ___insert prompt_____. I've identified the following variables and types that I think I need. Are the data types for any of these variables incorrect or are there better types I should use and why? Are there additional variables you think I need and why? Are there any names that should be changed to be more clear and why? |
Input and Output
- What input is needed for this program?
- What output is needed for this program?
Step 2: Writing your program
Open up your IDE and begin writing your program. A good place to start your program is to break it into four stages:
- data storage
- data input
- process data
- data output
The following template uses this model to help you get started. You can copy this template into a new .java file