Created
June 24, 2021 09:50
-
-
Save IT-Delinquent/c5c14285cab696c215c11d59073a623b to your computer and use it in GitHub Desktop.
musicArtistsWithAlbumsList
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #A class for holding info on music artists | |
| class MusicArtist{ | |
| [String]$Name | |
| [Int]$Age | |
| [Album[]]$Albums | |
| } | |
| #A class for holding info on music albums | |
| class Album{ | |
| [String]$Name | |
| [String]$DateReleased | |
| } | |
| #Creating a new list to hold music artists using the MusicArtist class | |
| $musicArtists = New-Object 'System.Collections.Generic.List[PSObject]' | |
| #Creating a new MusicArtist model (modelled after Roy Orbison, liberty taken with the age) | |
| $royOrbison = [MusicArtist]::new() | |
| $royOrbison.Name = 'Roy Orbison' | |
| $royOrbison.Age = 85 | |
| #Creating two albums to put into the $royOrbison object | |
| $lonelyAndBlue = [Album]::new() | |
| $lonelyAndBlue.Name = 'Lonely and Blue' | |
| $lonelyAndBlue.DateReleased = 'January 1961' | |
| $inDreams = [Album]::new() | |
| $inDreams.Name = 'In Dreams' | |
| $inDreams.DateReleased = 'July 1963' | |
| #Adding the albums to the $royOrbison Albums arrays | |
| $royOrbison.Albums += $lonelyAndBlue | |
| $royOrbison.Albums += $inDreams | |
| #Adding the $royOrbison object to the $musicArtists list | |
| $musicArtists.Add($royOrbison) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment