Skip to main content

Object-Oriented Programming Activity: Python Digital Pets Game

Downloaded: 80

Last edit: 20 April 2022

Resource Type Teaching Resources, Example Programs and Live Lessons
Key Stage 16-18 Years (KS5)
Curriculum Topic Algorithmic Thinking, Computational Thinking, Programming

A Python translation of Austin Henley's original Java homework task, shared with permission and with thanks to the original author. 

Skeleton Python code is provided that runs a basic digital pets game with actions such as Eat and Exercise. Tasks are provided that require students to extend the game by adding more pet species, more actions, and editing the main() program code, using key principles of object-oriented programming, including: 

  • changing attribute access modifiers (name mangling)
  • implementing and using a constructor method
  • implementing and using getters and setters
  • using inheritance to create subclasses
  • abstract methods
  • static methods
  • linking objects through association (composition)

Code is commented and the tasks are embedded in the comments.

I am currently not providing Task 2 answer code publicly as this is an assessed homework but can send via email upon request. 

 

Edit history

Nela Brockington | 20.04.22

Fixed typo in description.

Nela Brockington | 20.04.22

Minor edit to activity description.

Nela Brockington | 20.04.22

Minor edit to activity description.

Nela Brockington | 20.04.22

Added answer code for Task 1 A, B, C.

Nela Brockington | 20.04.22

Minor edits to activity description.

Nela Brockington | 20.04.22

Minor edit to title and description.

Nela Brockington | 20.04.22

Initial creation