Skip to main content

Object-Oriented Programming Activity: Python Digital Pets Game

Downloaded: 630

Last edit: 10 January 2024

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

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 | 10.01.24

Allow commenting.

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

Discuss: Object-Oriented Programming Activity: Python Digital Pets Game (2022-04-20)

Please login to post a comment

Unlock