-
Notifications
You must be signed in to change notification settings - Fork 4
/
Classes.ps1
72 lines (61 loc) · 1.61 KB
/
Classes.ps1
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
enum ComputerType {
SurfaceBook
HPLaptop
IPAD
ChromeBook
}
class SimonWahlinUserClass {
# Properties
[string] $GivenName
[string] $Surname
[int] $BirthYear
[string] $FullName
hidden [string] $Age
# Constructor: Creates a new SimonWahlinUserClass object, with the specified name
SimonWahlinUserClass([String] $GivenName, [string] $Surname, [int] $Year) {
Write-Verbose -Message 'With year!' -Verbose
# Set name for SimonWahlinUserClass
$this.GivenName = $GivenName
$this.Surname = $Surname
$this.FullName = '{0} {1}' -f $GivenName, $Surname
# SimonWahlinUserClass($GivenName,$Surname)
$this.BirthYear = $Year
$this.Age = (Get-Date).Year - (Get-Date -Year $Year).Year
}
SimonWahlinUserClass([string] $GivenName, [string] $Surname) {
Write-Verbose -Message 'Without year' -Verbose
$this.GivenName = $GivenName
$this.Surname = $Surname
$this.FullName = '{0} {1}' -f $GivenName, $Surname
}
# Method: Method that changes $Name to the default name
[void] UpdateAge() {
$this.Age = (Get-Date).Year - (Get-Date -Year $this.BirthYear).Year
}
[string] ToString() {
$string = '{0};{1}' -f $this.FullName, $this.BirthYear
return $string
}
}
enum MemberAccess {
Read = 1
Write = 2
Delete = 4
Execute = 8
}
function Register-Computer {
[CmdletBinding()]
param (
[ComputerType]
$ComputerType,
[MemberAccess[]]
$Access
)
begin {
}
process {
$ComputerType
}
end {
}
}