- Joined
- May 11, 2018
- Posts
- 3,631
- Solutions
- 5
- Reaction
- 5,768
- Points
- 1,610
KAILANGAN KO TULONG NYO MGA PAPS
We will create an Admin class, which is a child class of the User class. Follow and write the equivalent PHP scripts or answer with an explanation from the instructions listed below.
We will create an Admin class, which is a child class of the User class. Follow and write the equivalent PHP scripts or answer with an explanation from the instructions listed below.
1. Create a user class.
2. Add to the class a private property with the name of $username.
3. Create a setter method that can set the value of the $username.
4. Create a class Admin that inherits the User class.
5. Now, let’s add to the Admin class some code. First, add a public method by the name of expressYourRole, and make it return the string: “Admin”.
6. Add to the Admin class another public method, sayHello, that returns the string “Hello admin, XXX” with the username instead of XXX.
7. Create an object $admin1 out of the class Admin, set its name to “Balthazar”, and sayhello to the user. Do you see any problem?
8. What do you think is the cause of the problem?
9. How will you fix this problem?