Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP OOP

For this PHP code exercise we will explore Object Oriented Programming in PHP by creating Shape classes: Shape.php, Rectangle.php, and Circle.php.

Shape.php is the base class. Shape class requirements are:

  • A class constant named SHAPE_TYPE with a value of 1.
  • Four properties with different visibilities: a public name, a protected length and width, and a private id.
  • A constuctor which accepts a length and width parameter to initialize the respective properties.
  • A public area method which calculates and returns the area of the Shape object.
  • A public static getTypeDescription method which returns the string Type: with the SHAPE_TYPE concatenated to the end.
  • Getter and Setter methods for the name property.

Rectangle.php should inherit from the Shape class. Rectangle class requirements are:

  • A class constant named SHAPE_TYPE with a value of 2.

Circle.php should inherit from the Shape class. Circle class requirements are:

  • A class constant named SHAPE_TYPE with a value of 3.
  • A protected radius property.
  • A constuctor which accepts a radius parameter and initializes the radius property. **Don't forget to call the Shape class constructor.
  • A public area method which calculates and returns the area of the Circle object.

Just getting started?

Review the PHP Code Exercises documentation for more details on performing code exercises.

Need help?

Jump on the PHP channel in Slack and ask your fellow students and mentors for a hint.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages