2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,92 @@
#Requires -Version 5.0
Class Player
{
<#
Properties: Name, Team, Position and Number
#>
[string]$Name
[ValidateSet("Baltimore Ravens","Cincinnati Bengals","Cleveland Browns","Pittsburgh Steelers",
"Chicago Bears","Detroit Lions","Green Bay Packers","Minnesota Vikings",
"Houston Texans","Indianapolis Colts","Jacksonville Jaguars","Tennessee Titans",
"Atlanta Falcons","Carolina Panthers","New Orleans Saints","Tampa Bay Buccaneers",
"Buffalo Bills","Miami Dolphins","New England Patriots","New York Jets",
"Dallas Cowboys","New York Giants","Philadelphia Eagles","Washington Redskins",
"Denver Broncos","Kansas City Chiefs","Oakland Raiders","San Diego Chargers",
"Arizona Cardinals","Los Angeles Rams","San Francisco 49ers","Seattle Seahawks")]
[string]$Team
[ValidateSet("C","G","T","QB","RB","WR","TE","DT","DE","ILB","OLB","CB","S","K","H","LS","P","KOS","R")]
[string]$Position
[ValidateRange(0,99)]
[int]$Number
<#
Constructor: Creates a new Player object, with the specified Name, Team, Position and Number.
#>
Player([string]$Name, [string]$Team, [string]$Position, [int]$Number)
{
$this.Name = (Get-Culture).TextInfo.ToTitleCase("$Name")
$this.Team = (Get-Culture).TextInfo.ToTitleCase("$Team")
$this.Position = $Position.ToUpper()
$this.Number = $Number
}
<#
Methods: Trade the player to a different team (optional parameters for methods in PowerShell 5 classes are not available. Boo!!)
An overloaded method is a method with the same name as another method but in a different context,
in this case with different parameters.
#>
Trade([string]$NewTeam)
{
[string[]]$league = "Baltimore Ravens","Cincinnati Bengals","Cleveland Browns","Pittsburgh Steelers",
"Chicago Bears","Detroit Lions","Green Bay Packers","Minnesota Vikings",
"Houston Texans","Indianapolis Colts","Jacksonville Jaguars","Tennessee Titans",
"Atlanta Falcons","Carolina Panthers","New Orleans Saints","Tampa Bay Buccaneers",
"Buffalo Bills","Miami Dolphins","New England Patriots","New York Jets",
"Dallas Cowboys","New York Giants","Philadelphia Eagles","Washington Redskins",
"Denver Broncos","Kansas City Chiefs","Oakland Raiders","San Diego Chargers",
"Arizona Cardinals","Los Angeles Rams","San Francisco 49ers","Seattle Seahawks"
if ($NewTeam -in $league | Where-Object {$_ -notmatch $this.Team})
{
$this.Team = (Get-Culture).TextInfo.ToTitleCase("$NewTeam")
}
else
{
throw "Invalid Team"
}
}
Trade([string]$NewTeam, [int]$NewNumber)
{
[string[]]$league = "Baltimore Ravens","Cincinnati Bengals","Cleveland Browns","Pittsburgh Steelers",
"Chicago Bears","Detroit Lions","Green Bay Packers","Minnesota Vikings",
"Houston Texans","Indianapolis Colts","Jacksonville Jaguars","Tennessee Titans",
"Atlanta Falcons","Carolina Panthers","New Orleans Saints","Tampa Bay Buccaneers",
"Buffalo Bills","Miami Dolphins","New England Patriots","New York Jets",
"Dallas Cowboys","New York Giants","Philadelphia Eagles","Washington Redskins",
"Denver Broncos","Kansas City Chiefs","Oakland Raiders","San Diego Chargers",
"Arizona Cardinals","Los Angeles Rams","San Francisco 49ers","Seattle Seahawks"
if ($NewTeam -in $league | Where-Object {$_ -notmatch $this.Team})
{
$this.Team = (Get-Culture).TextInfo.ToTitleCase("$NewTeam")
}
else
{
throw "Invalid Team"
}
if ($NewNumber -in 0..99)
{
$this.Number = $NewNumber
}
else
{
throw "Invalid Number"
}
}
}

View file

@ -0,0 +1,2 @@
$player1 = [Player]::new("sam bradford", "philadelphia eagles", "qb", 7)
$player1

View file

@ -0,0 +1,2 @@
$player1.Trade("minnesota vikings", 8)
$player1

View file

@ -0,0 +1,2 @@
$player2 = [Player]::new("demarco murray", "philadelphia eagles", "rb", 29)
$player2

View file

@ -0,0 +1,2 @@
$player2.Trade("tennessee titans")
$player2

View file

@ -0,0 +1,3 @@
trait Shape {
fn area(self) -> i32;
}

View file

@ -0,0 +1,9 @@
struct Square {
side_length: i32
}
impl Shape for Square {
fn area(self) -> i32 {
self.side_length * self.side_length
}
}

View file

@ -0,0 +1,7 @@
trait Shape {
fn area(self) -> i32;
fn is_shape(self) -> bool {
true
}
}