Stub in first demo bits
This commit is contained in:
parent
3bceab65d9
commit
7e13f22a32
31
c&s20150725/demo.go
Normal file
31
c&s20150725/demo.go
Normal 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
25
c&s20150725/demo.php
Normal 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));
|
Loading…
Reference in New Issue
Block a user