Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kramit committed Oct 20, 2019
2 parents 15689d8 + de11c74 commit cdeec49
Show file tree
Hide file tree
Showing 4 changed files with 74 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","US")

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

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

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

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

# Hidden Props
Hidden [string] $cO2Output

#paramless constructor
car ()
{

}

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

# 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
}

#Method
[string] getDriverSide()
{
$side=$null
if ($this.country -eq "US"){
$side = "left"
} elseif ($this.country -eq "UK") {
$side = "right"
}
return $side
}
}
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="good"><td>Circle</td><td>Good Service</td></tr><tr class="good"><td>District</td><td>Good Service</td></tr><tr class="good"><td>Hammersmith &amp; City</td><td>Good Service</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>09/27/2019 23:24:12</i></div>
<br><hr><div class="footer"><i>04/14/2019 23:08:53</i></div>
</body></html>

0 comments on commit cdeec49

Please sign in to comment.