-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbowling-action.php
87 lines (80 loc) · 1.63 KB
/
bowling-action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
Project: Test
Date: 21/10/12
Author: Russell
*/
class action{
var $name;
var $arm;
var $jump;
var $speed;
var $skill1;
var $skill2;
function set($name, $arm, $jump, $speed)
{
$this->name = $name;
if( $arm == 'l' || $arm == 'left' )
{
$this->arm = 'Left';
}
if( $arm == 'r' || $arm == 'right' )
{
$this->arm = 'Right';
}
$this->jump = (int)$jump;
$this->speed = (int)$speed;
$this->skill1 = (int)rand(0,100);
$this->skill2 = (int)rand(0,100);
}
function runup()
{
if( $this->speed > $this->skill1 )
{
$smooth = true;
}else{
$smooth = false;
}
return $smooth;
}
function jump()
{
if( $this->runup() == true && $this->jump > $this->skill2 )
{
$perfect = true;
}else{
$perfect = false;
}
return $perfect;
}
function display()
{
if( $this->jump == true)
{
$say = '<p>
<strong>The ball was delivered '.$this->arm.' handed by '.$this->name.' with great skill!</strong>
</p>';
}else if( $this->jump == false )
{
$say = '<p>
<strong>The ball was delivered '.$this->arm.' handed by '.$this->name.' with little skill!</strong>
</p>';
}
return $say.'
<p>
Skill One '.($this->speed).' / '.($this->skill1).'
</p>
<p>
Skill Two '.($this->jump).' / '.($this->skill2).'
</p>';
}
}
#############################
#############################
##USAGE Example
#############################
#############################
$bowler = new action;
$bowler->set('Steven Finn', 'r', rand(0,100), rand(0,100));
echo $bowler->display();
?>