Python Forum
OOP Code help! - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: OOP Code help! (/thread-2749.html)



OOP Code help! - ajaY - Apr-06-2017

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


RE: OOP Code help! - sparkz_alot - Apr-06-2017

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.


RE: OOP Code help! - nilamo - Apr-07-2017

Why are there setters and getters? This is python, not a shitty language full of duplicate code.


RE: OOP Code help! - snippsat - Apr-07-2017

(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.