Post by Eric on Feb 3, 2008 16:25:40 GMT
I know it's Sunday, but this has nothing to do with the challenge, that will come in a little bit.
So this is a little game that I thought up and thought I'd try out over here. The whole point of this game is to take something simple, and to expand it by adding more and more features. For this one we'll use PHP, as it seems commonly used around here and has a lot of fun-filled features.
So let me start off with an example:
Person A:
<?php
echo "Hello, World!";
?>
Person B: Let's make it a function for easy use!
<?php
function helloWorld()
{
echo "Hello, World!";
}
?>
Person A: Well if it's a function, how about if we want to say hello to something other than the world?
<?php
function hello($entity)
{
echo "Hello, " . $entity . "!";
}
?>
Person B: How about another greeting aside from "Hello"?
<?php
function greet($greeting, $entity)
{
echo $greeting . ", " . $entity . "!";
}
?>
Person C: This should be an object, because everything should be an object!
<?php
class Greeter
{
protected $greeting;
protected $entity;
public function __construct($gr, $en)
{
$this->greeting = $gr;
$this->entity = $en;
}
public function greet()
{
echo $this->greeting . ", " . $this->entity . "!";
}
}
?>
And so on...
And from this you should be able to get the idea. The point of this is not to make improvements, but rather more features. Realistically, the best thing you could do with this is leave it alone as echo "Hello, World!" But, it's interesting to see how something that starts off small can get large.
Now in this one that we'll do as a group, I'll post the starting one. Then the next person adds something (giving a reason isn't really necessary, that was just there for an example). Then the person after that adds on to the person who posted before them. So we continuously expand on the script, adding new features and "improvements."
Let's start with something basic:
<?php
/* Month Printer
* Prints the names of the month
*/
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
for($m = 0; $m < count($months); $m++)
{
print ($m + 1) . ": " . $months[$m];
}
?>
Let the fun begin!
So this is a little game that I thought up and thought I'd try out over here. The whole point of this game is to take something simple, and to expand it by adding more and more features. For this one we'll use PHP, as it seems commonly used around here and has a lot of fun-filled features.
So let me start off with an example:
Person A:
<?php
echo "Hello, World!";
?>
Person B: Let's make it a function for easy use!
<?php
function helloWorld()
{
echo "Hello, World!";
}
?>
Person A: Well if it's a function, how about if we want to say hello to something other than the world?
<?php
function hello($entity)
{
echo "Hello, " . $entity . "!";
}
?>
Person B: How about another greeting aside from "Hello"?
<?php
function greet($greeting, $entity)
{
echo $greeting . ", " . $entity . "!";
}
?>
Person C: This should be an object, because everything should be an object!
<?php
class Greeter
{
protected $greeting;
protected $entity;
public function __construct($gr, $en)
{
$this->greeting = $gr;
$this->entity = $en;
}
public function greet()
{
echo $this->greeting . ", " . $this->entity . "!";
}
}
?>
And so on...
And from this you should be able to get the idea. The point of this is not to make improvements, but rather more features. Realistically, the best thing you could do with this is leave it alone as echo "Hello, World!" But, it's interesting to see how something that starts off small can get large.
Now in this one that we'll do as a group, I'll post the starting one. Then the next person adds something (giving a reason isn't really necessary, that was just there for an example). Then the person after that adds on to the person who posted before them. So we continuously expand on the script, adding new features and "improvements."
Let's start with something basic:
<?php
/* Month Printer
* Prints the names of the month
*/
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
for($m = 0; $m < count($months); $m++)
{
print ($m + 1) . ": " . $months[$m];
}
?>
Let the fun begin!