I am just learning object oriented programming, and this is the purpose I just gave:
"Create a class called Book that contains the stock number, author, title, price and number of pages for the book. Include a method that sets all data files and another that prints values for each data field. Create a class diagram and write a pseudocode that defines class. "
(remember, I am not writing code for a specific language, because I do not know) I created 5 attributes on request:
-stockNumber: num -price: num -pageCount: num -author: string -title: string
Now I need to create one method that immediately sets all the data. This is what turns me off.
Is there a general way to handle this in one method? or is my teacher wrong, and is it better to have several recruitment methods?
source share