From 9c86b5d6087471d111fae701ea9e5120584f55ad Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Wed, 5 Sep 2018 20:58:12 -0500 Subject: [PATCH] Proofreading classes pages --- code/classes-inheritance.php | 2 +- code/classes-visibility.php | 4 ++-- code/classes.php | 1 + code/static.php | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/code/classes-inheritance.php b/code/classes-inheritance.php index f1eed47..2bbb2cd 100644 --- a/code/classes-inheritance.php +++ b/code/classes-inheritance.php @@ -27,7 +27,7 @@ class Tractor extends Vehicle } } -// Outputs "driving slowly..." instead of "driving...". +// The drive function now outputs "driving slowly..." instead of "driving...". $tractor = new Tractor(); $tractor->drive(); diff --git a/code/classes-visibility.php b/code/classes-visibility.php index 2833608..509e89b 100644 --- a/code/classes-visibility.php +++ b/code/classes-visibility.php @@ -35,7 +35,7 @@ class Phone2 // The "protected" and "private" keywords work a little differently. // They both prevent functions and properties from being accessed outside an object. -// However, a method or property marked "protected" can still be accessed by a child object. +// However, a method or property marked "protected" can still be accessed by a child class. class Phone3 { private $number; @@ -49,7 +49,7 @@ class Phone3 } // In class "Smartphone", the "caller" property is accessible because the parent class -// has it marked as "protected". However, "Smartphone" cannot access the the "number" property +// has it marked as "protected". However, "Smartphone" cannot access the "number" property // because it is still listed as private. class Smartphone extends Phone3 { diff --git a/code/classes.php b/code/classes.php index c3e6a19..039d816 100644 --- a/code/classes.php +++ b/code/classes.php @@ -43,6 +43,7 @@ class Tricycle } } +// You can execute a method on an object using the same "->" arrow characters. $bike = new Tricycle(); $bike->color = 'Red'; $bike->echoColor(); diff --git a/code/static.php b/code/static.php index 1050bcc..ceba59f 100644 --- a/code/static.php +++ b/code/static.php @@ -45,8 +45,8 @@ $skyscraper = new Skyscraper(); echo $skyscraper->color . "\n"; // Often, you will see static constructors in PHP. -// A static constructor creates a new instance of an object. Why would do that when you just use "new Class" to create -// a new object? The most common reason is to make the code more readable. +// A static constructor creates a new instance of an object. Why would do that when you can just use "new Class" to create +// the object? The most common reason is to make the code more readable. class TinyHouse { private $color; @@ -66,5 +66,5 @@ class TinyHouse } } -// Using "build" can make more sense than "new", but it is ultimately a personal choice. +// Using "build" can make more sense than "new", but it is ultimately a personal preference. $house = TinyHouse::build('Blue', 4, true);