8000 GitHub - Morg3an/plp-week5-assignment: This is the assignment submission for week 5 of the Power Learn Project Software Development Course
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Morg3an/plp-week5-assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

🏠 Superhero Class Design – Week 5 Assignment

Welcome to the Object-Oriented Programming Assignment for Week 5!
This activity challenges you to design your own class, use constructors, encapsulation, and add an inheritance layer for real-world modeling.


📁 Folder Structure

week-5-assignment/
├── superhero.py           # Contains the Superhero class and logic
├── main.py                # Entry point to create and interact with superhero objects
├── polymorphism-challenge/
│   ├── vehicles.py       # Contains polymorphism challenge classes
│   ├── main.py           # Polymorphism demo entry
│   └── README.md         # Polymorphism challenge README
└── README.md             # You're reading this!

🔧 Assignment Overview

👩‍💻 Create Your Own Class

We created a class called Superhero that includes:

  • Attributes: name, power, health, and catchphrase
  • Constructor: Initializes each superhero with unique values
  • Methods:
    • introduce(): Prints out the hero's name and catchphrase
    • take_damage(amount): Reduces health
    • heal(amount): Restores health

🌟 Inheritance Layer

We also created a subclass (e.g. FlyingSuperhero) that:

  • Inherits from Superhero
  • Adds a method fly() to simulate flight
  • Overrides the introduce() method to add flight info

This demonstrates encapsulation and polymorphism in action.


▶️ How to Run the Program

1. Navigate to the base folder:

cd week-5-assignment

2. Run the main program:

python main.py

You'll be able to see superheroes created, damaged, healed, and performing actions like flying.


✅ Sample Output

Meet Thunderbolt! “Justice never sleeps!"
Thunderbolt took 30 damage!
Thunderbolt healed 20 health!
Thunderbolt is flying through the sky! ✨
Hi, I'm Thunderbolt, the flying superhero! ✈️

Polymorphism Challenge – Week 5 Assignment

Welcome to the Polymorphism Challenge for Week 5!
This challenge is designed to help you understand and practice polymorphism in Python using a real-world concept: vehicles with different modes of movement. 🚣️✈️🌊



📚 Objective

Implement polymorphism by creating a base class called Vehicle with a method move().
Then create multiple subclasses (e.g., Car, Plane, Boat) that each override the move() method with their own unique behavior.

This demonstrates how different objects can share the same method name but behave differently.


🚗 Classes Overview

🔹 Vehicle (Base Class)

  • Method: move() – A generic method for moving.

🔸 Car (Subclass)

  • Overrides move() – Prints "Driving on the road..."

✈️ Plane (Subclass)

  • Overrides move() – Prints "Flying through the sky..."

🚤 Boat (Subclass)

  • Overrides move() – Prints "Sailing across the water..."

▶️ How to Run the Program

1. Navigate to the folder:

cd week-5-assignment/polymorphism-challenge

2. Run the program:

python main.py

You’ll see different movement styles printed by each vehicle class, demonstrating polymorphism 535C in action.


✅ Sample Output

Driving on the road... 🚗
Flying through the sky... ✈️
Sailing across the water... 🚤

About

This is the assignment submission for week 5 of the Power Learn Project Software Development Course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0