John Ken wrote:how could i insert the variables directly into the string literal here?
also how could i have passed the instance of Person
why should i have used __toString() instead of getInfo()?
John Ken wrote:Do you want me to create a child class for the class Person or what, we can't pass an instance of Person without extending or creating a child class from Parent class.
Stephan van Hulst wrote:You passed a string to the book constructor. I told you to pass an instance of Person.
Create an instance of Person.
Assign it to a variable.
Pass the variable to the constructor when you create an instance of Book.
Stephan van Hulst wrote:Do you know how to create an instance of a class? Do you know how to assign such an instance to a variable? Do you know how to pass the values of variables to method calls?
John Ken wrote:A class is a template for objects, and an object is an instance of class.
John Ken wrote:
Stephan van Hulst wrote:2.Do you know how to assign an instance of a created class to a variable?
Not exactly.
John Ken wrote:
Stephan van Hulst wrote:3.Do you know how to pass the value of a variable to a method call?
yes like below:-
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |