Make answers to the following problems below using PHP. For now, you can
psuedocode the methods with comments,
or you can create your own implementations if you feel adventurous. Use any
resources you like. Also, one thing I forgot to mention in your lesson: there is
a naming convention for things in classes. If a name starts with a single
underscore, it's likely to be private
or protected
. For this example, any
names with a leading underscore, mark it as protected
. If you have any
questions, feel free to ask.
Example of pseudo-coded method
class Foo {
public function bar($data) {
/* Make sure to put it into comments, otherwise your editor with flip its shit.
if $data is array
foreach $item in $data
do_stuff($item)
else
return false
*/
}
}
id
first_name
last_name
user_name
email
password
last_logged_in
active
save()
- Saves the user to some sort of persistant storage (database, file, etc)load()
- Load the user from persistant storagedrop()
- Delete the user from persistant storageget_full_name()
- Gets the user's full name with the format"{first_name} {last_name}"
get_comments()
- Gets the user's comments
id
poster_id
date_created
date_published
last_edited
content
_published
- Defaults toFALSE
save()
load()
drop()
publish()
is_published()
get_comments()
Comments
- are made by
User
s - are added to
Blog_Post
s - have content
- have a day they were created
- have a score based on up and down votes
- must be saved
- must be loadable
- can be deleted
- can be upvoted and downvoted