Jump to content


Photo

The Super Cool Mostly Official Frankenstein-Code Game Thread!


  • Please log in to reply
20 replies to this topic

#1 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 29 October 2006 - 07:34 PM

Okay I have been inspired by one of steelman's (though it pains me to admit it  :P) posts to make a game.  P.s. - Don't be jealous of the awesomeness of my game name!

Okay here's how it works: It's just like those threads on other message boards where everybody contributes to making a story by posting the next sentence/few sentences/paragraph or whatever, except for we are gonna take the script and the next poster adds his/her little piece to it.

The code you add doesn't have to really 'conform' to any particular theme or situation or goal or whatever, but it does have to be somehow useable or relavent to the script as a whole.  In other words, if you wish to create a new arm for Frankenstein-Code, that's fine and dandy, but it has to be attached to his body, not just some random arm laying there. 

Also, the script has to be "self-contained." No database stuff.  No flatfile stuff.  I don't want people to have to go setting up and altering databases all the time, or having to mess with dir structures/permissions/whatever.  Also no cookies. And keep it strictly PHP, as in, no adding in javascript or some other such thing. These rules may or may not be relaxed, depending on how this game progresses and what comes of it. 

Also, it should go without saying, but I'm gonna say it anyways, so that one cannot argue they "didn't know" : No malicious code, no vulgar or pornographic content, etc..

Now, in order to keep the code consistent and not have like 3 different people posting 'at the same time' or something, here's what we're gonna do: If you wanna be the next person to add to the script, make a 'placeholder' post, saying "placeholder" or "I'm next" or "get off my koolaid yo" or something.  Then copy the code from the previous post, add your piece to it, and then edit your placeholder post. 

p.s. - Please use code tags when posting. Also, even though coding styles differ, things like indenting in some way are standard, so do it.

Okay so I guess I'll start with the cheezy but fitting:

<?php
   echo "Hello World!";
?>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 29 October 2006 - 08:13 PM

<?php
class Greeting
{
   function Greeting()
   {
      echo "Hello World!";
   }
}

$greet = new Greeting();
?>

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 29 October 2006 - 09:28 PM

<?php
class Greeting
{
   function Greeting()
   {
      echo "Hello World!";
   }
}
interface Actor
{
	public function speak();	
	public function meet($person);	
}
class Franky implements Actor
{	
	private $person;
	
	public function meet($person){
		$this->person = $person;
	}
	public function speak(){
		if($this->person == null){
			$greet = new Greeting();
			echo '<br />';
		}
			else {
			echo 'Hello '.$this->person.'!<br />';
		}
	}
}
$h = new Franky;
$h->speak();
$h->meet('Jesus');
$h->speak();
?>

Ha! I've forced php5 upon you.  :P Franky is born..

#4 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 29 October 2006 - 10:26 PM

<?php
$relatives = array('mother', 'father', 'sister', 'brother','uncle', 'auntie');
$verbs = array('dislikes', 'sits on', 'licks', 'sucks', 'looks like', 'does', 'discusses the pros and cons of Web 2.0', 'loves', 'caresses', 'slides onto', 'hates', 'kisses', 'learns PHP with', 'has an AJAX interface with');
$animals = array('dogs', 'cats', 'horses', 'birds', 'giraffes', 'elephants', 'hippos', 'hamsters', 'gerbils', 'monkeys');

function insult($secondary_person)
{
   global $relatives;
   global $verbs;
   global $animals;

   $r_size = sizeof($relatives) - 1;
   $v_size = sizeof($verbs) - 1;
   $a_size = sizeof($animals) - 1;

   $r_rand = rand(0, $r_size);
   $v_rand1 = rand(0, $v_size);
   $v_rand2 = rand(0, $v_size);
   $a_rand = rand(0, $a_size);
   $insult = "Your {$relatives[$r_rand]} {$verbs[$v_rand1]} $secondary_person and {$verbs[$v_rand1]} {$animals[$a_rand]}";
   
   return $insult;
}

class Greeting
{
   function Greeting()
   {
      echo "Hello World!";
   }
}
interface Actor
{
	public function speak();	
	public function meet($person);	
}
class Franky implements Actor
{	
	private $person;
	
	public function meet($person){
		$this->person = $person;
	}
	public function speak($insult_them = false){
		if($this->person == null){
			$greet = new Greeting();
			echo '<br />';
		}
			else {
			echo 'Hello '.$this->person.'!<br />';
                 if ($insult_them)
                 {
                    echo insult($this->person) . '<br />';
		      }
           }
	}
}
$h = new Franky;
$h->speak();
$h->meet('Jesus');
$h->speak(true);
?>

edit: i am not responsible for the output of this sample program. if you find it offends, then blame PHP, not me. everything in the above code is clean, non-offensive English.
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#5 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 29 October 2006 - 11:06 PM

Ouch, franky learned some new phrases..  :P

#6 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 29 October 2006 - 11:11 PM

Ouch, franky learned some new phrases..  :P

dirty little sod, aint he?!
BTW, can we standardise spaces/tabs? when it gets really tempting to try this out in our fave text editor, it doesnt always work for some reason unless the tabs/spaces are deleted+replaced. no idea why...
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#7 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 30 October 2006 - 05:55 AM

crap. i meant to say no php5 as well. oh well. i can do that.  i guess if someone can't do php5 then tough titties. okay do you guys' posts ^ mean to serve as placeholders or what?

nevermind, i will decide for you.  unless your thread specificially states "placeholder/whatever" then it doesn't count as a placeholder. 

okay i just added something quick cuz i have to go soon:
<?php
$relatives = array('mother', 'father', 'sister', 'brother','uncle', 'auntie');
$verbs = array('dislikes', 'sits on', 'licks', 'sucks', 'looks like', 'does', 'discusses the pros and cons of Web 2.0', 'loves', 'caresses', 'slides onto', 'hates', 'kisses', 'learns PHP with', 'has an AJAX interface with');
$animals = array('dogs', 'cats', 'horses', 'birds', 'giraffes', 'elephants', 'hippos', 'hamsters', 'gerbils', 'monkeys');

function insult($secondary_person)
{
   global $relatives;
   global $verbs;
   global $animals;

   $r_size = sizeof($relatives) - 1;
   $v_size = sizeof($verbs) - 1;
   $a_size = sizeof($animals) - 1;

   $r_rand = rand(0, $r_size);
   $v_rand1 = rand(0, $v_size);
   $v_rand2 = rand(0, $v_size);
   $a_rand = rand(0, $a_size);
   $insult = "Your {$relatives[$r_rand]} {$verbs[$v_rand1]} $secondary_person and {$verbs[$v_rand1]} {$animals[$a_rand]}";
   
   return $insult;
}

class Greeting
{
   function Greeting()
   {
      echo "Hello World!";
   }
}
interface Actor
{
	public function speak();	
	public function meet($person);	
}
class Franky implements Actor
{	
	private $person;
	
	public function meet($person){
		$this->person = $person;
	}
	public function speak($insult_them = false){
		if($this->person == null){
			$greet = new Greeting();
			echo '<br />';
		}
			else {
			echo 'Hello '.$this->person.'!<br />';
                 if ($insult_them)
                 {
                    echo insult($this->person) . '<br />';
		      }
           }
	}
}
if ($_POST['name']) {
   $h = new Franky;
   $h->speak();
   $h->meet($_POST['name']);
   $h->speak(true);
} else {
echo <<<FORMINT
What's your best friend's name?<br/>
<form action = '{$_SERVER['PHP_SELF']}' method = 'post'>
<input type = 'text' name = 'name' size = '10'>
<input type = 'submit' value = 'submit'>
</form>
FORMINT;
}
?>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#8 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 30 October 2006 - 11:16 AM

You cheated a little C_V...

You made $h->meet('Jesus'); into $h->meet($_POST['name']); ! The way I understand your rules, we can only add to the scenario, not replace anything. Anyway, you're the boss, so I guess we're keeping it..

As for using php5, I don't think it would be a real Frankenstein if it wasn't a complete and utter chaos of different styles and fashions. Meaning if you can't do php5, you can still add. You won't be able to run Franky unless you have php5 installed, obviously, but I will be happy to display the fruits of the works of those that don't!

Speaking of chaos, I added some intestants to Franky starting with his stomach. Turns out Franky has quite the appetite:

Hello World!
Hello Mister President!
Your auntie discusses the pros and cons of Web 2.0 Mister President and discusses the pros and cons of Web 2.0 giraffes
Franky liky to eats elephants..
Franky liky to eats elephants..
Franky liky to eats hamsters..
Franky liky to eats gerbils..
Franky liky to eats cats..
Franky liky to eats dogs..
Franky liky to eats elephants..

Bhaarf..
Franky liky to eats birds..

Bhaarf..


LOL, "Web 2.0 giraffes"?  :P

Chaos code:

<?php
$relatives = array('mother', 'father', 'sister', 'brother','uncle', 'auntie');
$verbs = array('dislikes', 'sits on', 'licks', 'sucks', 'looks like', 'does', 'discusses the pros and cons of Web 2.0', 'loves', 'caresses', 'slides onto', 'hates', 'kisses', 'learns PHP with', 'has an AJAX interface with');
$animals = array('dogs', 'cats', 'horses', 'birds', 'giraffes', 'elephants', 'hippos', 'hamsters', 'gerbils', 'monkeys');

function insult($secondary_person)
{
   global $relatives;
   global $verbs;
   global $animals;

   $r_size = sizeof($relatives) - 1;
   $v_size = sizeof($verbs) - 1;
   $a_size = sizeof($animals) - 1;

   $r_rand = rand(0, $r_size);
   $v_rand1 = rand(0, $v_size);
   $v_rand2 = rand(0, $v_size);
   $a_rand = rand(0, $a_size);
   $insult = "Your {$relatives[$r_rand]} {$verbs[$v_rand1]} $secondary_person and {$verbs[$v_rand1]} {$animals[$a_rand]}";
   
   return $insult;
}
class Greeting
{
   function Greeting()
   {
      echo "Hello World!";
   }
}
interface Singleton
{
	public static function getInstance();
}
interface Actor
{
	public function speak();	
	public function meet($person);
	public function eat($animalArr);
}
abstract class Intestant_Abstract
{
	abstract public function input($input);	
	abstract public function output();
}
class Stomach extends Intestant_Abstract implements Singleton
{
	private static $instance;
	
	public static function getInstance() {
	   if (!isset(self::$instance)) {
	       self::$instance = new self;
	   }
	   return self::$instance;
	}
	private function __construct(){	
	}
	public $kilosOfFood;
	public function input($input){
		$this->kilosOfFood += strlen($input);
		echo 'Franky liky to eats '.$input.'..<br />';
		if($this->kilosOfFood > (strlen(implode('',$GLOBALS['animals']))/1.5)){
			$this->output();
		}
	}
	public function output(){
		echo '<br />Bhaarf..<br />';
	}
}
class Guts implements ArrayAccess, Singleton
{
	private static $instance;
	
	public static function getInstance() {
	   if (!isset(self::$instance)) {
	       self::$instance = new self;
	   }
	   return self::$instance;
	}
	private function __construct(){
	}
	private $intestants;
	
	public function add($name){
		$this->intestants[$name] = call_user_func(array($name, 'getInstance'));
	}
	public function remove($key) {
		unset($this->intestants[$key]);
	}
	public function offsetExists($offset) {
		return isset($this->intestants[$offset]);
	}
	public function offsetGet($offset) {
		return $this->intestants[$offset];
	}
	public function offsetSet($name, $value) {
		$this->add($name);
	}
	public function offsetUnset($offset) {
		unset($this->intestants[$offset]);
	}	
}
class Franky implements Actor
{	
	
	private $person;
	
	public function meet($person){
		$this->person = $person;
	}
	function eat($animals){
		shuffle($animals);
		$guts = Guts::getInstance();
		$guts->add('Stomach');
		$guts['Stomach']->input(next($animals));
	}
	public function speak($insult_them = false){
		if($this->person == null){
			$greet = new Greeting();
			echo '<br />';
		}
			else {
			echo 'Hello '.$this->person.'!<br />';
                 if ($insult_them)
                 {
                    echo insult($this->person) . '<br />';
		      }
           }
	}
}
if (isset($_POST['name'])) {
   $h = new Franky;
   $h->speak();
   $h->meet($_POST['name']);
   $h->speak(true);
   $h->eat($animals);
   $h->eat($animals);
      $h->eat($animals);
         $h->eat($animals);
            $h->eat($animals);
               $h->eat($animals);
                  $h->eat($animals);
                     $h->eat($animals);
} else {
echo <<<FORMINT
What's your best friend's name?<br/>
<form action = '{$_SERVER['PHP_SELF']}' method = 'post'>
<input type = 'text' name = 'name' size = '10'>
<input type = 'submit' value = 'submit'>
</form>
FORMINT;
}
?>


#9 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 30 October 2006 - 11:30 AM

oops. this line:
$verbs = array('dislikes', 'sits on', 'licks', 'sucks', 'looks like', 'does', 'discusses the pros and cons of Web 2.0', 'loves', 'caresses', 'slides onto', 'hates', 'kisses', 'learns PHP with', 'has an AJAX interface with');

should be
'discusses the pros and cons of Web 2.0 with'
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#10 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 30 October 2006 - 11:38 AM

oops. this line:

$verbs = array('dislikes', 'sits on', 'licks', 'sucks', 'looks like', 'does', 'discusses the pros and cons of Web 2.0', 'loves', 'caresses', 'slides onto', 'hates', 'kisses', 'learns PHP with', 'has an AJAX interface with');

should be
'discusses the pros and cons of Web 2.0 with'


Don't worry about it, it's meant to be a little jibberish, right? It's not like what I added is "solid code", by any standard!  :P

#11 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 30 October 2006 - 03:46 PM

Yeah I meant no php5 on account of some people maybe people unable to test it if they don't have it installed, yes.  But who cares.

Cheating? Bah!  I don't consider that cheating.  In fact, I'm surprised the original "hello world" is still there.  Why? Because I can put "Jesus" into the input field and it will in essence be do the same thing as before. 

p.s. - rewriting code to run more efficiently or "better" is okay too.  I'm certainly not the most php saavy person here; for instance you guys' OOP skills are much better than mine. So if you feel like "Franky" is somehow being crippled because of his internals, rewriting/reorganizing is okay - to an extent.  We don't want complete rewrites every single post, I guess.  But, well..well for instance, exactly how redbull turned the simple "hello world" into a method inside a class.

LoL, I ran the code and this is what I got:

Hello World!
Hello Isaac!
Your mother slides onto Isaac and slides onto gerbils
Franky liky to eats birds..
Franky liky to eats dogs..
Franky liky to eats giraffes..
Franky liky to eats gerbils..
Franky liky to eats monkeys..
Franky liky to eats giraffes..
Franky liky to eats gerbils..

Bhaarf..
Franky liky to eats hamsters..

Bhaarf..


Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#12 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 30 October 2006 - 04:03 PM

<placeholder>
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#13 KevinM1

KevinM1
  • Moderators
  • Snarkimus Prime
  • 5,248 posts

Posted 30 October 2006 - 04:05 PM

Hehe, this is pretty interesting to read from a newb's point of view.  Quick question: I'm a bit lost at

<?php

class Guts implements ArrayAccess, Singleton

?>

As I don't see ArrayAccess defined anywhere.  Am I missing something, or just blind?
Using 'global' is a sign of doing it wrong

#14 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 30 October 2006 - 04:07 PM

ArrayAccess is an SPL interface, it's build-in into 5.1+

Edit: Don't use this code as an example to learn OOP, PLEASE. It's structure is at fault, I just threw something together quickly. Consider that the disclaimer.

#15 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 30 October 2006 - 04:21 PM

ArrayAccess is an SPL interface, it's build-in into 5.1+

Edit: Don't use this code as an example to learn OOP, PLEASE. It's structure is at fault, I just threw something together quickly. Consider that the disclaimer.

lol an "Insult" generator and a person that eats animals and chucks up - beats "Hello World" any day :)
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#16 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 30 October 2006 - 04:54 PM

Hey C_V, c'mon give us Franky back, we wanna play some more.. :P

#17 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 30 October 2006 - 04:59 PM

okay I thought I'd make a new post instead of editing the last one, since it's on a new page.

Okay, It's all about.. Bride of Franky!
<?php
$relatives = array('mother', 'father', 'sister', 'brother','uncle', 'auntie');
$verbs = array('dislikes', 'sits on', 'licks', 'sucks', 'looks like', 'does', 'discusses the pros and cons of Web 2.0', 'loves', 'caresses', 'slides onto', 'hates', 'kisses', 'learns PHP with', 'has an AJAX interface with');
$animals = array('dogs', 'cats', 'horses', 'birds', 'giraffes', 'elephants', 'hippos', 'hamsters', 'gerbils', 'monkeys');
$adjectives = array('abhorrent','abject','abnormal','abrasive','absorbed','absurd',
'abusive','acrid','agonizing','ambiguous','ancient','apathetic',
'average','bad','barbarous','bawdy','belligerent','berserk',
'bizarre','black','boorish','brash','brawny','burly',
'callous','cold','colossal','combative','crabby','craven',
'crazy','creepy','crooked','cynical','demonic','deranged',
'devilish','direful','dirty','disagreeable','draconian','drunk',
'dysfunctional','erratic','evasive','evil','filthy','flippant',
'gaudy','giant','gigantic','greedy','grotesque','grouchy',
'gruesome','grumpy','guiltless','hellish','horrible','huge',
'hulking','icky','immense','irate','jaded','jittery',
'macho','maddening','malicious','mammoth','maniacal','massive',
'mighty','mindless','moaning','moldy','murky','mysterious',
'nasty','nauseating','noxious','oafish','obscene','psychotic',
'rabid','ruthless','sassy','scary','smelly','snobbish',
'snotty','spooky','threatening','tightfisted','tough','towering',
'trashy','ugly','unbecoming','unsightly','vagabond','vengeful',
'venomous','vulgar','wicked','wrathful','wretched');

function insult($secondary_person)
{
   global $relatives;
   global $verbs;
   global $animals;

   $r_size = sizeof($relatives) - 1;
   $v_size = sizeof($verbs) - 1;
   $a_size = sizeof($animals) - 1;

   $r_rand = rand(0, $r_size);
   $v_rand1 = rand(0, $v_size);
   $v_rand2 = rand(0, $v_size);
   $a_rand = rand(0, $a_size);
   $insult = "Your {$relatives[$r_rand]} {$verbs[$v_rand1]} $secondary_person and {$verbs[$v_rand1]} {$animals[$a_rand]}";
   
   return $insult;
}
class Greeting
{
   function Greeting()
   {
      echo "Hello World!";
   }
}
interface Singleton
{
	public static function getInstance();
}
interface Actor
{
	public function speak();	
	public function meet($person);
	public function eat($animalArr);
}
abstract class Intestant_Abstract
{
	abstract public function input($input);	
	abstract public function output();
}
class Stomach extends Intestant_Abstract implements Singleton
{
	private static $instance;
	
	public static function getInstance() {
	   if (!isset(self::$instance)) {
	       self::$instance = new self;
	   }
	   return self::$instance;
	}
	private function __construct(){	
	}
	public $kilosOfFood;
	public function input($input){
		$this->kilosOfFood += strlen($input);
		echo 'Franky liky to eats '.$input.'..<br />';
		if($this->kilosOfFood > (strlen(implode('',$GLOBALS['animals']))/1.5)){
			$this->output();
		}
	}
	public function output(){
		echo '<br />Bhaarf..<br />';
	}
}
class Guts implements ArrayAccess, Singleton
{
	private static $instance;
	
	public static function getInstance() {
	   if (!isset(self::$instance)) {
	       self::$instance = new self;
	   }
	   return self::$instance;
	}
	private function __construct(){
	}
	private $intestants;
	
	public function add($name){
		$this->intestants[$name] = call_user_func(array($name, 'getInstance'));
	}
	public function remove($key) {
		unset($this->intestants[$key]);
	}
	public function offsetExists($offset) {
		return isset($this->intestants[$offset]);
	}
	public function offsetGet($offset) {
		return $this->intestants[$offset];
	}
	public function offsetSet($name, $value) {
		$this->add($name);
	}
	public function offsetUnset($offset) {
		unset($this->intestants[$offset]);
	}	
}
class Franky implements Actor
{	
	
	private $person;
	
	public function meet($person){
		$this->person = $person;
	}
	function eat($animals){
		shuffle($animals);
		$guts = Guts::getInstance();
		$guts->add('Stomach');
		$guts['Stomach']->input(next($animals));
	}
	public function speak($insult_them = false){
		if($this->person == null){
			$greet = new Greeting();
			echo '<br />';
		}
			else {
			echo 'Hello '.$this->person.'!<br />';
                 if ($insult_them)
                 {
                    echo insult($this->person) . '<br />';
		      }
           }
	}
}
if (isset($_POST['relativeName'])) {
   $relativeName = $_POST['relativeName'];
   $relativeType = $_POST['relativeType'];
   $h = new Franky;
   $h->speak();
   $h->meet($relativeName);
   $h->speak(true);
   $h->eat($animals);
   $h->eat($animals);
      $h->eat($animals);
         $h->eat($animals);
            $h->eat($animals);
               $h->eat($animals);
                  $h->eat($animals);
                     $h->eat($animals);

$monstername = $adjectives[array_rand($adjectives)];
echo "<br/>Franky wants to marry your $relativeType.<br/>";
echo "$relativeName will join the monster family and<br/>";
echo "$relativeName's monster name will be $relativeName the $monstername.<br/>";
} else {
$person = $relatives[array_rand($relatives)];
echo <<<FORMINT
What's your $person's name?<br/>
<form action = '{$_SERVER['PHP_SELF']}' method = 'post'>
<input type = 'text' name = 'relativeName' size = '10'>
<input type = 'hidden' name = 'relativeType' value = '$person'>
<input type = 'submit' value = 'submit'>
</form>
FORMINT;
}
?>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#18 fert

fert
  • Members
  • PipPipPip
  • Advanced Member
  • 1,114 posts

Posted 12 November 2006 - 03:23 AM

<?php
$relatives = array('mother', 'father', 'sister', 'brother','uncle', 'auntie');
$verbs = array('dislikes', 'sits on', 'licks', 'sucks', 'looks like', 'does', 'discusses the pros and cons of Web 2.0', 'loves', 'caresses', 'slides onto', 'hates', 'kisses', 'learns PHP with', 'has an AJAX interface with');
$animals = array('dogs', 'cats', 'horses', 'birds', 'giraffes', 'elephants', 'hippos', 'hamsters', 'gerbils', 'monkeys');
$adjectives = array('abhorrent','abject','abnormal','abrasive','absorbed','absurd',
'abusive','acrid','agonizing','ambiguous','ancient','apathetic',
'average','bad','barbarous','bawdy','belligerent','berserk',
'bizarre','black','boorish','brash','brawny','burly',
'callous','cold','colossal','combative','crabby','craven',
'crazy','creepy','crooked','cynical','demonic','deranged',
'devilish','direful','dirty','disagreeable','draconian','drunk',
'dysfunctional','erratic','evasive','evil','filthy','flippant',
'gaudy','giant','gigantic','greedy','grotesque','grouchy',
'gruesome','grumpy','guiltless','hellish','horrible','huge',
'hulking','icky','immense','irate','jaded','jittery',
'macho','maddening','malicious','mammoth','maniacal','massive',
'mighty','mindless','moaning','moldy','murky','mysterious',
'nasty','nauseating','noxious','oafish','obscene','psychotic',
'rabid','ruthless','sassy','scary','smelly','snobbish',
'snotty','spooky','threatening','tightfisted','tough','towering',
'trashy','ugly','unbecoming','unsightly','vagabond','vengeful',
'venomous','vulgar','wicked','wrathful','wretched');

function insult($secondary_person)
{
   global $relatives;
   global $verbs;
   global $animals;

   $r_size = sizeof($relatives) - 1;
   $v_size = sizeof($verbs) - 1;
   $a_size = sizeof($animals) - 1;

   $r_rand = rand(0, $r_size);
   $v_rand1 = rand(0, $v_size);
   $v_rand2 = rand(0, $v_size);
   $a_rand = rand(0, $a_size);
   $insult = "Your {$relatives[$r_rand]} {$verbs[$v_rand1]} $secondary_person and {$verbs[$v_rand1]} {$animals[$a_rand]}";
   
   return $insult;
}
class Greeting
{
   function Greeting()
   {
      echo "Hello World!";
   }
}
interface Singleton
{
	public static function getInstance();
}
interface Actor
{
	public function speak();	
	public function meet($person);
	public function eat($animalArr);
}
abstract class Intestant_Abstract
{
	abstract public function input($input);	
	abstract public function output();
}
class Stomach extends Intestant_Abstract implements Singleton
{
	private static $instance;
	
	public static function getInstance() {
	   if (!isset(self::$instance)) {
	       self::$instance = new self;
	   }
	   return self::$instance;
	}
	private function __construct(){	
	}
	public $kilosOfFood;
	public function input($input){
		$this->kilosOfFood += strlen($input);
		echo 'Franky liky to eats '.$input.'..<br />';
		if($this->kilosOfFood > (strlen(implode('',$GLOBALS['animals']))/1.5)){
			$this->output();
		}
	}
	public function output(){
		echo '<br />Bhaarf..<br />';
	}
}
class Guts implements ArrayAccess, Singleton
{
	private static $instance;
	
	public static function getInstance() {
	   if (!isset(self::$instance)) {
	       self::$instance = new self;
	   }
	   return self::$instance;
	}
	private function __construct(){
	}
	private $intestants;
	
	public function add($name){
		$this->intestants[$name] = call_user_func(array($name, 'getInstance'));
	}
	public function remove($key) {
		unset($this->intestants[$key]);
	}
	public function offsetExists($offset) {
		return isset($this->intestants[$offset]);
	}
	public function offsetGet($offset) {
		return $this->intestants[$offset];
	}
	public function offsetSet($name, $value) {
		$this->add($name);
	}
	public function offsetUnset($offset) {
		unset($this->intestants[$offset]);
	}	
}
class Franky implements Actor
{	
	
	private $person;
	
	public function meet($person){
		$this->person = $person;
	}
	function eat($animals){
		shuffle($animals);
		$guts = Guts::getInstance();
		$guts->add('Stomach');
		$guts['Stomach']->input(next($animals));
	}
	public function speak($insult_them = false){
		if($this->person == null){
			$greet = new Greeting();
			echo '<br />';
		}
			else {
			echo 'Hello '.$this->person.'!<br />';
                 if ($insult_them)
                 {
                    echo insult($this->person) . '<br />';
		      }
           }
	}
}

function say($lang1,$lang2)
{
	echo $lang1." rocks and ".$lang2." sucks";
}

if (isset($_POST['relativeName'])) {
   $relativeName = $_POST['relativeName'];
   $relativeType = $_POST['relativeType'];
   $h = new Franky;
   $h->speak();
   $h->meet($relativeName);
   $h->speak(true);
   $h->eat($animals);
   $h->eat($animals);
      $h->eat($animals);
         $h->eat($animals);
            $h->eat($animals);
               $h->eat($animals);
                  $h->eat($animals);
                     $h->eat($animals);

$monstername = $adjectives[array_rand($adjectives)];
echo "<br/>Franky wants to marry your $relativeType.<br/>";
echo "$relativeName will join the monster family and<br/>";
echo "$relativeName's monster name will be $relativeName the $monstername.<br/>";
} else {
$person = $relatives[array_rand($relatives)];
echo <<<FORMINT
What's your $person's name?<br/>
<form action = '{$_SERVER['PHP_SELF']}' method = 'post'>
<input type = 'text' name = 'relativeName' size = '10'>
<input type = 'hidden' name = 'relativeType' value = '$person'>
<input type = 'submit' value = 'submit'>
</form>
FORMINT;
}

if(isset($_GET[lang1])
{
	say($_GET[lang1],$_GET[lang2]);
}
else
{
	echo "<form action=".$_SERVER[PHP_SELF]." method=get>Language 1:<input type=\"text\" name=\"lang1\"><p>Language 2:<input type=\"text\" name=\"lang2\"></p></form>";
}
?>


Si hoc legere scis nimium eruditionis habes
Gentoo Linux 2007.0 Firefox 2

#19 dalecosp

dalecosp
  • Members
  • PipPipPip
  • Advanced Member
  • 418 posts
  • LocationMissouri

Posted 26 August 2015 - 09:15 PM

Fert:  Franky doesn't parse now.  You're missing a closing parenthesis here:

if(isset($_GET[lang1])
{


<placeholder>


"God doesn't play dice" --- Albert Einstein
"Perl is hardly a paragon of beautiful syntax." --- Weedpacket

#20 scootstah

scootstah
  • Moderators
  • Advanced Member
  • 3,864 posts
  • LocationUSA

Posted 27 August 2015 - 12:44 AM

You know this thread is like 9 years old, right?
while(!$succeed = try());




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users