Python Forum

Full Version: OOP Code help!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Implement the following classes from the following UML class diagrams, instantiate some objects and show the functionality of the classes. 
1.      Person (5 marks)
Person
+Name:string
+Age:integer
+DisplayInfo():void




2.      Fire Alarm (10 marks)
FireAlarm
-ringing:boolean
+StartTheAlarm():void
+StopAlarm():void
+IsAlarmRinging():boolean
 
 
3.      Dice (10 marks)



Dice
-RolledNumber:integer
+RollTheDice():void
+GetDiceNumber():integer


4.       
 



4.      Employee (15 marks)



Employee
-FirstName:string
-LastName:string
-EmployeeNum:int
-Salary:integer
+SetFullName(string, string):void
+GetFullName():string
+GetFirstName():string
+GetLastName():string
+SetEmployeeNumber(integer)
+GetEmployeeNumber():integer
+SetSalary(integer):void
+GetSalary():integer
+GetMonthlyWage():float
I missed what the question is.  This forum is here to answer questions, not do the work for you. Please refer to the Help Doc for information on how to properly post a thread.
Why are there setters and getters? This is python, not a shitty language full of duplicate code.
(Apr-07-2017, 05:51 PM)nilamo Wrote: [ -> ]Why are there setters and getters? This is python, not a shitty language full of duplicate code.
It's annoying and unfortunately a common thing.
People that are coming from from Java/C++,
and think Python OOP work in the same way.
MIT(has Python as main language did use Java before) teach this:
Quote:is strongly advice to always use getters and setters and not access data attribute directly.
Had a post about here.