OOP Fundamentals · Course lab · about 180 minutes · 6 tasks · marked out of 100, pass at 60

The fee system with policies, and a repair shop on paper

The situation

Build the academy fee system properly: students that guard their own invariants, fee policies that vary without a single isinstance check, payments composed rather than inherited. Then design a mobile-repair shop on paper before touching code — because paper before code is the professional order — and rehearse the seven interview questions with your own examples.

What you'll be able to show

  • Guard an object's invariants with methods, and prove the guards fail loudly
  • Choose inheritance or composition and defend the choice in one sentence
  • Replace type checks with polymorphism — a billing loop with zero isinstance
  • Design from nouns and invariants on paper before implementing

What you need

  • Python 3 (any editor), the classes from lessons 2–4
  • A sheet of paper for the design task
  • A friend or a phone camera for the rehearsal

Tasks

  1. 1Student, guarded
    Write Student with private fee fields, a guarded pay() and balance(). Try to break it: pay a negative amount, overpay, then add refund(amount) that refuses to refund more than was paid. Each guard must raise, not print.
    A correct result: Three attempts to break it, each raising an exception with a clear message.
  2. 2Inherit, then compose
    Write NavttcStudent(Student) with attendance and eligibility, overriding fee_status(). Then add payments as a list of Payment objects (amount, date) inside Student. Write one sentence on why Payment is composed, not inherited.
    A correct result: A child class that overrides one method, a composed Payment list, and the sentence.
  3. 3Policies, and a loop with zero isinstance
    Write the abstract FeePolicy and Regular, Installment and Scholarship policies. Give each Student a policy object. Write ONE billing loop over a mixed list printing each student's monthly amount. Count the isinstance checks in your code.
    A correct result: A billing loop over mixed policies; isinstance count: zero.
  4. 4The repair shop, on paper
    Model: customers bring phones; each job has a diagnosis, parts and labour; some jobs are warranty (no charge but parts tracked); customers get an SMS when ready. Underline the nouns, write the invariants, and decide inheritance vs policy for warranty jobs — on paper, with a photo.
    A correct result: A photographed page: classes, invariants, and the warranty decision with a reason.
  5. 5Two classes from the paper
    Implement the two most interesting classes from your design with their guards. Test each guard once.
    A correct result: Two classes whose guards raise on the invariant they protect.
  6. 6The interview rehearsal
    Answer all seven battery questions using your fee-system and repair-shop examples, aloud, to a friend or a camera, in under ten minutes. Get feedback or watch it once, tighten the two weakest answers, and do it again.
    A correct result: Two recordings or two rounds of feedback; the two answers you tightened named.

What to hand in

The Python file(s), the photographed design page, the guard test outputs, and the names of the two answers you tightened after the first rehearsal.

How it is marked

CriterionPoints
Student guards raise on all three attacks and refund is guarded 20
Inheritance and composition each used correctly with the sentence 15
Policy hierarchy with a billing loop and zero isinstance 25
Paper design has classes, invariants and a defended warranty decision 20
Two classes implemented with tested guards 10
Rehearsal done twice with named improvements 10
Total · pass at 60 100

Hand in your lab

Create a free BvLogic ID to hand in your lab, get it marked, and have it on your certificate.

Create your BvLogic ID

Already have one? Sign in and this course will be added to it.