Where we have to create the OOP_constructor page. Below the class we have to create a new object, and pass the required data (manufacturer and colour) to the constructor function. I don't understand why there are set and get Functions? Because I use a construct function for all the data and a Display function, after the class i create the new object and call the display function to display the data of the constructor.So i see it unnecessary for set and get, but each set and get functions counts two points.
I get your point of view,but for me its just like alot of unnecessary code that will take extra time, just imagine the hundreds of set,get,set,get's that one must write. Your example of telephone nr, I will just code a new object for the numbers then change that value of that object parameter if a customer wants to change their phone number. Actually if i could have it my way, i was just gonna put it in an array and loop it through, but well its constructors.
Registered: 7 years ago
Getters and setters are a normal part of OOP and you may just as well get used to them.
Basically they are just a means of providing public access, in a controlled manner, to data members which are otherwise encapsulated within objects of a class.
It is quite a big jump from structured programming to OOP, but when you get used to OOP you will wonder how / why you ever did it any other way.