Stub in first demo bits

This commit is contained in:
Dan Buch 2015-07-25 13:53:04 -04:00
parent 3bceab65d9
commit 7e13f22a32
2 changed files with 56 additions and 0 deletions

31
c&s20150725/demo.go Normal file
View File

@ -0,0 +1,31 @@
package main
import "fmt"
type Person struct {
Name string
}
func NewPerson(name string) *Person {
return &Person{
Name: name,
}
}
func (p *Person) Wave() string {
return p.Name + " is waving"
}
func (p *Person) WaveAt(other *Person) string {
return p.Name + " waves at " + other.Name
}
func main() {
boo := NewPerson("Boo")
fmt.Printf("%#v\n", boo.Wave())
hay := NewPerson("Hay")
fmt.Printf("%#v\n", hay.Wave())
fmt.Printf("%#v\n", boo.WaveAt(hay))
}

25
c&s20150725/demo.php Normal file
View File

@ -0,0 +1,25 @@
<?php
class Person {
public $name;
public function wave()
{
return $this->name. ' is waving';
}
public function waveAt(Person $waveTarget)
{
return $this->name . ' waves at ' . $waveTarget->name;
}
}
$boo = new Person();
$boo->name = 'Boo';
var_dump($boo->wave());
$hay = new Person();
$hay->name = 'Hay';
var_dump($hay->wave());
var_dump($boo->waveAt($hay));