0% found this document useful (0 votes)
10 views14 pages

Programming Class Assignments

Uploaded by

shaishavparekh23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views14 pages

Programming Class Assignments

Uploaded by

shaishavparekh23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment - 1

Task - 1
 Declare the class Person and add properties firstname and lastname in it.
 Add the parameterized method named career with parameter name dream_career
and return a dynamic string with the use of given parameter.
i.e. return “ wants to become $dream_career (parameter of method Career)”.
Task - 1
 Create an instance of class Person.
 Set the value of firstname and lastname using object and print using echo.
 Use the career method with first and last name and print a sentence as per given
example.
i.e. Meet Shah wants to become a Software Engineer.
Task - 2
 In previous task, we wrote a career($dream_career) method in Person class.
 In this task, we'll add the ability to use the $this keyword to approach class
properties in the career($dream_career) method.
Task - 2
 Reference:-
Task - 2
 Add the ability to approach the $firstName and $lastName properties to the
Career($dream_career) method, so that the string “Meet Shah wants to become a
Software Engineer." can be returned.
 Echo Career($dream_career) method using object of class Person.
Task - 3
 Declare class named Ministry and add property $ministerName and
$minitryName in it.
 Add constructor and set values in declared properties using $this keyword.
 Add destructor and print string like “Shri Amit Shah is the Minister of Home
Affairs.” using echo in it.
Task - 4
 Write a program using access modifiers where you have to use public, protected
and private modifiers.
Task - 5
 Write a separate programs according to types of inheritance.
Task - 6
 Create an abstract class named galaxy.
 Create an abstract method named planets().
 Create a simple method named galaxyTypes() in abstract class and print some
data.
 Create an another class named galaxyData and declare an object for the class and
print all data using that object without any error.
Task - 7
 Create an Employee class with a protected $empname property and methods that
can set and get the $empname.
 Create an Admin interface with the following abstract methods that can give the
user an array of privileges. The first method is setAdminPrivileges(), and it gets a
parameter of $array, and the second method is getAdminPrivileges().
Task - 7
 Create a Staff interface with methods to set and get the staff's privileges.
 Create an Users class that extends the Employee class and implements
the Admin and the Staff interfaces.
 Create an object of User class, set employee name and privileges and write the
code to get the Employee name and privileges without any error.
Task - 8
 Write a separate programs to implement trait, constants, magic constants, static
and final keyword concepts.
Assignment -1

Thank You!

You might also like