Tamagotchi πΈπΆ
https://www.youtube.com/watch?v=tJE-5nIOXKI
We will today be creating a tamagotchi. A tamagotchi is a virtual pet that you can interact with. It was quite a big deal back when i was young. Not so much anymore.
A tamagotchi had to be kept alive. You could feed it, play with it, dress it etc.

Tamagotchi details
We have to create 4 different classes
Game
- Class that initiates a game and takes user inputTamagotchi
- Super class forCat
andDog
Cat
- A class that inherits fromTamagotchi
Dog
- A class that also inherits fromTamagotchi
Game
class
Game
classThis class can be seen as the "main" class. It takes data from a user and now creates either a Cat
object or a Dog
object.
Tamagotchi
class
Tamagotchi
classIs the super class for Cat
and Dog
. It contains the more general characteristics of Cat
and Dog
It could have some of the following attributes
name
age
mood
energy
.
And it could have some of the following methods. But its up to you!
play()
feed()
sleep(6)
...
Cat
and Dog
Cat
and Dog
The Cat
and Dog
should extend Tamagotchi
!
You come up with what attributes and methods relevant for a Cat
and a Dog
Fx a Dog
could maybe bark()
. It's up to you
One requirement is that both Cat
and Dog
should at some point override
a method from Tamagotchi
!
Requirements
Game
classTamagotchi
classCat
andDog
classes that extendsTamagotchi
In the
Cat
andDog
classes there should be at least one override methodDraw a class diagram of all your classes and create a sequence diagram of one specific use case
Your task
A user should be able to create either a Cat
or a Dog
with a name. That pet will then be created with random values.
Your task is now to create a Tamagotchi that is fun to play with using the above requirements! Create a new game object using the Game
class that can spawn a cat
, a dog
or both
Example
Hello, would you like to create a dog or a cat? Press 1 for dog and 2 for cat
1
Ahh you would like to create a cat, what should the name of the cat be?
Miaui McLickALot
Okay, here is your cat Miaui McLickALot
/\_/\
( o.o )
> ^ <
What would you now like to do?
1 - play
2 - feed
3 - sleep
1
Miaui McLickALot is running after a ball, now her energy went down 1 and her hunger went up 1
What would you now like to do?
1 - play
2 - feed
3 - sleep
3
|\ _,,,---,,_
ZZZzz /,`.-'`' -. ;-;;,_
|,4- ) )-,_. ,\ ( `'-'
'---''(_/--' `-'\_)
Miaui McLickALot now has full energy!
What would you now like to do?
1 - play
2 - feed
3 - sleep
This is just an example please come up with your own virtual pet πΈ
Optional tasks
Make the pet objects interact with each other
Create more pets than just
Cat
andDog
Make it possible for time to pass in the game! Fx if a pet has not gotten food in some time it becomes hungry. You could fx do that by in the
Game
class creating atick
method that simulates that time has elapsed. Thistick
method can then be called each second that then affects the pets statsYour idea here!
Handin
Hand in on fronter here: https://kea-fronter.itslearning.com/LearningToolElement/ViewLearningToolElement.aspx?LearningToolElementId=927870
Hand in via git!
Handin checklist
Have you tested that the code works?
Have you written comments to the code?
Have you thought of a good structure?
Is the code easy to understand and read?
Does the variablename make sense?
Last updated
Was this helpful?