Skip to content

Commit

Permalink
Add car class app
Browse files Browse the repository at this point in the history
  • Loading branch information
kramit committed Aug 18, 2019
1 parent 4e010d2 commit 149482d
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
18 changes: 18 additions & 0 deletions Classes/appCar.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Import-Module $PSScriptRoot\carClass.ps1


# Using Static "new" method
$redSportsCar = [car]::new("100","red")

# Using New-Object. Parameters for Argument list are positional and required by the constructor.
$blueSportsCar = New-Object car -ArgumentList "100", "red"

# Using a HashTable. Note: requires default or parameterless constructor.
$greenSportsCar = [car]@{
topSpeed = "100"
colour = "green"
}

# Dynamic Object Type using a variable name.
$type = "Car"
$whiteSportsCar = New-Object -TypeName $type
42 changes: 42 additions & 0 deletions Classes/carClass.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
class car
{
#Props
[Int32] $topSpeed
[string] $colour

# Static Props
Static [string] $UK = "Right"
Static [string] $US = "Left"

# Hidden Props

Hidden [string] $cO2Output

#paramless constructor
car ()
{

}

#constructor
car ([int32]$topSpeed,[string]$colour)
{
$this.topSpeed = $topSpeed
$this.colour = $colour
}

# Method
# add turbo 10% boost to top speed
[String] addTurbo()
{
$this.topSpeed = $this.topSpeed + (($this.topSpeed / 100)*10)

return "boost added top speed is now :"+$this.topSpeed
}

#Static method
Static [string] getTopSpeed()
{
return [car]::topspeed
}
}
7 changes: 6 additions & 1 deletion Classes/fruit class.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ Fruit([string]$name,[string]$colour)
{
$this.name = $name
$this.colour = $colour
$this.allvalue = {$name + $colour}
}

}

$thing = [Fruit]::new('apple','green')
$thing = [Fruit]::new($null,$null)

$thing.colour = "blue"
$thing.name = "banana"

$thing

4 changes: 2 additions & 2 deletions TFL/report.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</head><body>
<H1><U>TFL Line status</U></H1>
<hr>
<table><colgroup><col /><col /></colgroup><tr><th>Line Name</th><th>Status</th></tr><tr class="good"><td>Bakerloo</td><td>Good Service</td></tr><tr class="good"><td>Central</td><td>Good Service</td></tr><tr class="bad"><td>Circle</td><td>Minor Delays</td></tr><tr class="good"><td>District</td><td>Good Service</td></tr><tr class="bad"><td>Hammersmith &amp; City</td><td>Minor Delays</td></tr><tr class="good"><td>Jubilee</td><td>Good Service</td></tr><tr class="good"><td>Metropolitan</td><td>Good Service</td></tr><tr class="good"><td>Northern</td><td>Good Service</td></tr><tr class="good"><td>Piccadilly</td><td>Good Service</td></tr><tr class="good"><td>Victoria</td><td>Good Service</td></tr><tr class="good"><td>Waterloo &amp; City</td><td>Good Service</td></tr></table>
<table><colgroup><col /><col /></colgroup><tr><th>Line Name</th><th>Status</th></tr><tr class="good"><td>Bakerloo</td><td>Good Service</td></tr><tr class="good"><td>Central</td><td>Good Service</td></tr><tr class="good"><td>Circle</td><td>Good Service</td></tr><tr class="bad"><td>District</td><td>Part Closure</td></tr><tr class="bad"><td>Hammersmith &amp; City</td><td>Part Closure</td></tr><tr class="good"><td>Jubilee</td><td>Good Service</td></tr><tr class="good"><td>Metropolitan</td><td>Good Service</td></tr><tr class="good"><td>Northern</td><td>Good Service</td></tr><tr class="good"><td>Piccadilly</td><td>Good Service</td></tr><tr class="good"><td>Victoria</td><td>Good Service</td></tr><tr class="bad"><td>Waterloo &amp; City</td><td>Service Closed</td></tr></table>
<table>
</table>
<br><hr><div class="footer"><i>03/28/2019 09:17:02</i></div>
<br><hr><div class="footer"><i>04/14/2019 23:08:53</i></div>
</body></html>

0 comments on commit 149482d

Please sign in to comment.