-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoclass.php
More file actions
75 lines (74 loc) · 2.14 KB
/
autoclass.php
File metadata and controls
75 lines (74 loc) · 2.14 KB
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
<?php
class Auto{
##########################
## ##
## VARIABLEN ##
## ##
##########################
var $Farbe; //Variable definieren
private $KMstand; //Variable definieren
var $Verbrauch; //Variable definieren
var $Tankstand; //Variable definieren
var $maxTank; //Variable definieren
function fahren($KM){ //function fahren definieren
##########################################
## ##
## altes Fahren ohne Verbrauch ##
## ##
##########################################
/*
if ($this->KMstand>$this->KMstand+$KM){
$this->KMstand=$this->KMstand-$KM;
}
else{
$this->KMstand=$this->KMstand+$KM;
}
*/
/*
if (($this->Verbrauch)*($KM/100)>$Tankstand){
$this->KMstand=$this->KMstand+($this->Tankstand/$this->Verbrauch)*100;
$this->Tankstand=0;
}
else{
$this->KMstand=$this->KMstand+($this->Tankstand/$this->Verbrauch)*100;
//$this->KMstand=$this->KMstand+abs($KM); //Tanken mit Absoluten zahlen (keine Negativen)
}
*/
##########################################
## ##
## fahren mit Verbrauch ##
## ##
##########################################
if(abs($KM)<=$this->Tankstand/$this->Verbrauch*100){
$this->KMstand=$this->KMstand+abs($KM);
$this->Tankstand=$this->Tankstand-((abs($KM)/100)*$this->Verbrauch);
}
else{
$this->KMstand=$this->KMstand+(($this->Tankstand/$this->Verbrauch)*100);
$this->Tankstand=0;
}
}
##################################
## ##
## tanken mit maxTank ##
## ##
##################################
function tanken($Liter){ //function tanken defnieren
if ($this->Tankstand+$Liter>=$this->maxTank){ //Wenn Liter+Tankstand mehr als Maximaler Tankstand dann
$this->Tankstand=$this->maxTank; //setze Tankstand auf maximum
}
elseif($this->Tankstand+$Liter<0){ //Wenn Tankstand-Menge die Abgezapft wird ist kleiner als 0 dann
$this->Tankstand=0; //setze den Tankstand auf 0
}
else{
$this->Tankstand=$this->Tankstand+$Liter; //Wenn nichts zutrifft tanke normal.
}
}
function getKMstand(){
return $this->KMstand;
}
function setKMstand($KM){
echo 'Nur für authorisiertes Personal';
}
}
?>