Object Oriented Programming in PHP - Assignment 1 | Practice Sets and Coding Challenges

Assignment : 1

Introduction to Object Oriented Programming in PHP



Playlist:




Practice Questions


Q.1 :Write a PHP program to create class circle having radius data member and two member functions find_circumfernce () and find_area() . Display area and Circumference depending on user’s preference.



Q.2 : Create Class Collge and Class Department as base class and derived class respectively , Create one more class as Faculty to display it’s detail information.( Use the concept of interface)



Q.3 : Write PHP script to demonstrate the concept of introspection for examining object



Set A


Q.1 :Write class declarations and member function definitions for an employee(code, name, designation). Derive emp_account(account_no, joining_date) from employee and emp_sal(basic_pay, earnings, deduction) from emp_account. Write a menu driven program a) To build a master table b) To sort all entries c) To search an entry d) Display salary



Q.2 :Define an interface which has methods area( ), volume( ). Define constant PI. Create a class cylinder which implements this interface and calculate area and volume. (Hint: Use define( ))



Q.3 :Write a Calculator class that can accept two values, then add them, subtract them, multiply them together, or divide them on request



Set B


Q.1 : Create a class named DISTANCE with feet and inches as data members. The class has the following member functions: convert_feet_to_inch() , convert_inch_to_feet() . Display options using radio button and display conversion on next page.



Q.2 :Write a PHP program to create a class Employee that contains data members as Emp_Name, Dept_name , Basic_sal,DA, HRA,TA , IT,PF,PT , GROSS, DEDUCTION ,NET . It has member functions calculate_gross , calculate_deductions , Calculate_net_salary . Display pay slip of employee. Create and Initialize members Emp_Name, Dept_name , Basic_sal of Employee object by using parameterized constructor.



Q.3 : Write a PHP program to create a class temperature which contains data members as Celsius and Fahrenheit . Create and Initialize all values of temperature object by using parameterized constructor . Convert Celsius to Fahrenheit and Convert Fahrenheit to Celsius using member functions. Display conversion on next page.



Set C


Q.1 : Write a PHP program to create a class article having articleid, name, articleqty, price. Write menu driven program to perform following functions :( Use array of objects) i) Display details of all articles purchased. ii) Display details of articles whose price exceeds 500 iii) Display details of articles whose quantity exceeds 50



Q.2 : Write a PHP program to create a class Worker that has data members as Worker_Name, No_of_Days_worked, Pay_Rate. Create and initialize the object using default constructor, Parameterized constructor. Also write necessary member function to calculate and display the salary of worker.