Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5978933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:35:17+00:00 2026-05-22T21:35:17+00:00

I attempted to recreate a piece of code which is basically a minimalist Tomagatchi

  • 0

I attempted to recreate a piece of code which is basically a minimalist Tomagatchi like thing. However when it is fed, and listened to, it’s “mood” value does not change. It remains “mad”. Any help would be greatly appreciated!

{#Create name, hunger, boredom attributes. Hunger and Boredom are numberical attributes

class Critter(object):
    def __init__(self, name, hunger = 0, boredom = 0):
        self.name = name
        self.hunger = hunger
        self.boredom = boredom

    #Creating a private attribute that can only be accessed by other methods
    def __pass_time(self):
        self.hunger += 1
        self.boredom += 1

    def __get_mood(self):
        unhappiness = self.hunger + self.boredom
        if unhappiness < 5:
            mood = "happy"
        if 5 <= unhappiness <= 10:
            mood = "okay"
        if 11 <= unhappiness <= 15:
            mood = "frustrated"
        else:
            mood = "mad"
        return mood

    mood = property (__get_mood)

    def talk(self):
        print "Hi! I'm",self.name,"and I feel",self.mood,"now."
        self.__pass_time()

    def eat(self, food = 4):
        print "Brrruuup. Thank you!"
        self.hunger -= food
        if self.hunger < 0:
            self.hunger = 0
        self.__pass_time()

    def play(self, play = 4):
        print "Yaaay!"
        self.boredom -= play
        if self.boredom < 0:
            self.boredom = 0
        self.__pass_time()

    def main ():
        crit_name = raw_input("What do you want to name your critter? ")
        crit = Critter (crit_name)

    choice = None
    while choice != "0":
        print \
              """  0 - Quit
                   1 - Listen to your critter.
                   2 - Feed your critter
                   3 - Play with your critter
              """

        choice = raw_input ("Enter a number: ")

        #exit
        if choice == "0":
            print "GTFO."
        #listen to the critter
        elif choice == "1":
            crit.talk()
        #feed the crit crit critter
        elif choice == "2":
            crit.eat()
        #play with the crit crit critter
        elif choice == "3":
            crit.play()
        #some unknown choice
        else:
            print "\nwat"

    main ()
    raw_input ("\n\nHit enter to GTFO")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:35:17+00:00Added an answer on May 22, 2026 at 9:35 pm

    In _getMood, there should be elifs.

        if unhappiness < 5:
            mood = "happy"
        elif 5 <= unhappiness <= 10:
            mood = "okay"
        elif 11 <= unhappiness <= 15:
            mood = "frustrated"
        else:
            mood = "mad"
    

    Without them, it was actually only checking if unhappiness was between 11 and 15, and if not, setting the mood to mad. So unhappines from 0 to 10, and up from 16 meaned a critter was mad.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In trying to understand javascript best practices, I'm attempting to recreate a piece of
I attempted to write the following code to draw a cylinder. The cylinder was
Attempted translation of the above question from non-native English to English: This is a
I attempted to open a C#/VB form in designer mode, and instead of the
I attempted to open a Java bug last Halloween. I immediately got a response
I attempted to re-size two buttons in MSIE, so they would be extra-large but
I attempted to render a circle in opengl es 1.1 as a test before
My attempted solution was: $date = Nov 30 2009 03:00:00:000PM; echo date(F Y, strtotime($date));
Has anyone attempted this? Is it possible, and if so, what kind of problems
Possible Duplicate: Attempted SQL injection attack - what are they trying to do? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.