Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 (2 pts.) We have abstract class Student with protected property $name. Inheriting from this are classes Undergrad, with additional private property syear (one of

image text in transcribed

3 (2 pts.) We have abstract class Student with protected property $name. Inheriting from this are classes Undergrad, with additional private property syear (one of "freshman", "sophomore", .) and Gradstudent, with additional private property $semester (a positive integer: the student's semester of enrollment). An instance of Undergrad is created with initial values for $name and $year. An instance of Gradstudent is created with initial values for $name and $semester. Method setstatus () can be invoked on any instance of student (an instance of Undergrad or of Gradstudent), takes one argument Invoked on an Undergrad, it updates its syear property with the value passed to it. Invoked on a Gradstudent, it updates its $semester property with the value passed. Similarly, method getstatus () can be invoked on any student instance; it has no argument. Invoked on an Undergrad, it returns the value of its $name property. Invoked on a Grads tudent, it returns the value of its $semester property. When an instance of Undergrad appears where a string is expected, it returns a string of the form (name) (year where name> is the value of the $name property, and year) is the value of the $year property. When an instance of Gradstudent appears where a string is expected, it returns a string of the form (name) ((semester)) where (name) is the value of the $name property, and (semester) is the value of the $semester property code included. The following is a listing of script prob3Gap. php, with the class definitions removed and only some test setStatus ("senior"); echo $ed >getStatus() . " . Sken - new Gradstudent("Ken", 3) echo $ken "n" Sken -> setStatus (4 echo $ken -> getStatus) When this is executed at the command line, we get the followin g. C:ISomeFolder>php prob3.php Ed (junior) senior Ken (semester 3) We add a couple of final points. Abstract class Student should declare abstract protected methods setstatus () and getstatus( note that setstatus ) takes one argument while getstatus ) takes none. Define aconstruet ) method in student that initializes $name. Have the construct () methods for Undergrad and Gradstudent call their parent's _construct ) to initialize the $name property

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions