This session focuses on the Vikingos project, a practical application of Python fundamentals. It is entirely dedicated to practicing Object-Oriented Programming (OOP), functions, and encapsulation.
Through this project, I solidified my understanding of these concepts by applying my skills in a comprehensive and real-world scenario, improving my problem-solving abilities and coding proficiency.
The Vikings and Saxons are at war. Both are Soldiers, but they have their own methods of fighting. The Vikings have been transported to Python. YAY!!
In this lab, you will work with the concept of inheritance in Python.
You will find the following files in the folder for this lab:
vikingsClasses.py1-testSoldier.py2-testVikings.py3-testSaxons.py4-testWar.py
You are free to use any code editor you have to open these files.
Modify the file vikingsClasses.py so that all the tests pass.
- Modify
vikingsClasses.pyand save your changes.
The best way to know how our code is performing is to work with tests. You will test the vikingsClasses.py file step by step.
You will only be editing the vikingsClasses.py file. The files that you will run to test your code are: 1-testSoldier.py, 2-testVikings.py, 3-testSaxons.py, and 4-testWar.py, depending on how far you have progressed in your code.
So, let’s say you have already created the class for Soldiers.
- Write your code.
- Make sure to save the changes in your editor.
- In your terminal, run the test file for that class.
$ python3 1-testSoldier.py --v