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
-
1Student, guardedWrite 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.
-
2Inherit, then composeWrite 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.
-
3Policies, and a loop with zero isinstanceWrite 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.
-
4The repair shop, on paperModel: 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.
-
5Two classes from the paperImplement 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.
-
6The interview rehearsalAnswer 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
| Criterion | Points |
|---|---|
| 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 |
صورتحال
academy کا فیس system ٹھیک سے بنائیں: ایسے students جو اپنے invariants کی خود حفاظت کریں، ایسی fee policies جو ایک بھی isinstance check کے بغیر بدلیں، payments جو inherit نہیں compose ہوں۔ پھر code چھونے سے پہلے کاغذ پر ایک mobile-repair shop design کریں — کیونکہ code سے پہلے کاغذ ہی پیشہ ورانہ ترتیب ہے — اور اپنی مثالوں سے سات interview سوالوں کی مشق کریں۔
آپ کیا دکھا سکیں گے
- object کے invariants کی methods سے حفاظت کرنا، اور ثابت کرنا کہ guards زور سے ناکام ہوتے ہیں
- inheritance یا composition چننا اور ایک جملے میں انتخاب کا دفاع کرنا
- type checks کی جگہ polymorphism لانا — صفر isinstance والا billing loop
- implement کرنے سے پہلے کاغذ پر nouns اور invariants سے design کرنا
آپ کو کیا چاہیے
- Python 3 (کوئی بھی editor)، سبق 2–4 کی classes
- design کے کام کے لیے کاغذ کا ایک صفحہ
- مشق کے لیے ایک دوست یا phone camera
کام
-
1Student، محفوظprivate fee fields، guarded pay() اور balance() کے ساتھ Student لکھیں۔ اسے توڑنے کی کوشش کریں: منفی رقم ادا کریں، زیادہ ادا کریں، پھر refund(amount) شامل کریں جو ادا شدہ سے زیادہ واپس کرنے سے انکار کرے۔ ہر guard raise کرے، print نہیں۔درست نتیجہ: توڑنے کی تین کوششیں، ہر ایک واضح پیغام کے ساتھ exception raise کرے۔
-
2inherit کریں، پھر composeattendance اور eligibility کے ساتھ NavttcStudent(Student) لکھیں، fee_status() کو override کرتے ہوئے۔ پھر Student کے اندر payments کو Payment objects (amount، date) کی list کے طور پر شامل کریں۔ ایک جملہ لکھیں کہ Payment composed کیوں ہے، inherited کیوں نہیں۔درست نتیجہ: ایک child class جو ایک method override کرے، ایک composed Payment list، اور جملہ۔
-
3policies، اور صفر isinstance والا loopabstract FeePolicy اور Regular، Installment اور Scholarship policies لکھیں۔ ہر Student کو ایک policy object دیں۔ ملی جلی list پر ایک billing loop لکھیں جو ہر student کی ماہانہ رقم print کرے۔ اپنے code میں isinstance checks گنیں۔درست نتیجہ: ملی جلی policies پر billing loop؛ isinstance کی گنتی: صفر۔
-
4repair shop، کاغذ پرmodel کریں: گاہک phones لاتے ہیں؛ ہر job کی diagnosis، parts اور labour ہوتی ہے؛ کچھ jobs warranty ہیں (کوئی charge نہیں مگر parts track ہوتے ہیں)؛ تیار ہونے پر گاہک کو SMS جاتا ہے۔ اسموں کے نیچے لکیر لگائیں، invariants لکھیں، اور warranty jobs کے لیے inheritance یا policy کا فیصلہ کریں — کاغذ پر، تصویر کے ساتھ۔درست نتیجہ: ایک تصویر کھینچا ہوا صفحہ: classes، invariants، اور وجہ کے ساتھ warranty کا فیصلہ۔
-
5کاغذ سے دو classesاپنے design کی دو سب سے دلچسپ classes ان کے guards کے ساتھ implement کریں۔ ہر guard ایک بار test کریں۔درست نتیجہ: دو classes جن کے guards اس invariant پر raise کریں جس کی وہ حفاظت کرتے ہیں۔
-
6interview کی مشقساتوں battery سوالوں کے جواب اپنے fee-system اور repair-shop کی مثالوں سے، بلند آواز میں، کسی دوست یا camera کے سامنے، دس منٹ سے کم میں دیں۔ feedback لیں یا ایک بار دیکھیں، دو کمزور ترین جواب کسیں، اور دوبارہ کریں۔درست نتیجہ: دو recordings یا feedback کے دو دور؛ جو دو جواب آپ نے کسے ان کے نام۔
کیا جمع کروانا ہے
Python file(s)، design کے صفحے کی تصویر، guard کے test outputs، اور پہلی مشق کے بعد کسے ہوئے دو جوابوں کے نام۔
نمبر کیسے ملیں گے
| معیار | نمبر |
|---|---|
| Student کے guards تینوں حملوں پر raise کرتے ہیں اور refund محفوظ ہے | 20 |
| inheritance اور composition ہر ایک درست استعمال، جملے کے ساتھ | 15 |
| policy hierarchy billing loop اور صفر isinstance کے ساتھ | 25 |
| کاغذی design میں classes، invariants اور دفاع شدہ warranty فیصلہ | 20 |
| دو classes آزمائے ہوئے guards کے ساتھ implement ہوئیں | 10 |
| مشق دو بار ہوئی، نامزد بہتریوں کے ساتھ | 10 |
| کل · پاس 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 IDAlready have one? Sign in and this course will be added to it.