mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-16 19:05:05 +00:00
Add VB.NET implementation
This commit is contained in:
1 parent
f80413c2fd
commit
677aa91797
8 files changed
+621
No files matched your search
@@ -0,0 +1,73 @@
|
||||
Imports System.Collections.Generic
|
||||
|
||||
Public Class GildedRose
|
||||
Private Items As IList(Of Item)
|
||||
|
||||
Public Sub New(items As IList(Of Item))
|
||||
Me.Items = items
|
||||
End Sub
|
||||
|
||||
Public Sub UpdateQuality()
|
||||
For i = 0 To Items.Count - 1
|
||||
|
||||
If Items(i).Name <> "Aged Brie" AndAlso Items(i).Name <> "Backstage passes to a TAFKAL80ETC concert" Then
|
||||
|
||||
If Items(i).Quality > 0 Then
|
||||
|
||||
If Items(i).Name <> "Sulfuras, Hand of Ragnaros" Then
|
||||
Items(i).Quality = Items(i).Quality - 1
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
|
||||
If Items(i).Quality < 50 Then
|
||||
Items(i).Quality = Items(i).Quality + 1
|
||||
|
||||
If Items(i).Name = "Backstage passes to a TAFKAL80ETC concert" Then
|
||||
|
||||
If Items(i).SellIn < 11 Then
|
||||
|
||||
If Items(i).Quality < 50 Then
|
||||
Items(i).Quality = Items(i).Quality + 1
|
||||
End If
|
||||
End If
|
||||
|
||||
If Items(i).SellIn < 6 Then
|
||||
|
||||
If Items(i).Quality < 50 Then
|
||||
Items(i).Quality = Items(i).Quality + 1
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
If Items(i).Name <> "Sulfuras, Hand of Ragnaros" Then
|
||||
Items(i).SellIn = Items(i).SellIn - 1
|
||||
End If
|
||||
|
||||
If Items(i).SellIn < 0 Then
|
||||
|
||||
If Items(i).Name <> "Aged Brie" Then
|
||||
|
||||
If Items(i).Name <> "Backstage passes to a TAFKAL80ETC concert" Then
|
||||
|
||||
If Items(i).Quality > 0 Then
|
||||
|
||||
If Items(i).Name <> "Sulfuras, Hand of Ragnaros" Then
|
||||
Items(i).Quality = Items(i).Quality - 1
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
Items(i).Quality = Items(i).Quality - Items(i).Quality
|
||||
End If
|
||||
Else
|
||||
|
||||
If Items(i).Quality < 50 Then
|
||||
Items(i).Quality = Items(i).Quality + 1
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>GildedRoseKata</RootNamespace>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
Public Class Item
|
||||
Public Property Name As String
|
||||
Public Property SellIn As Integer
|
||||
Public Property Quality As Integer
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return Me.Name & ", " & Me.SellIn & ", " & Me.Quality
|
||||
End Function
|
||||
End Class
|
||||
@@ -0,0 +1,67 @@
|
||||
Imports System
|
||||
|
||||
Module Program
|
||||
Sub Main(args As String())
|
||||
Console.WriteLine("OMGHAI!")
|
||||
Dim Items As IList(Of Item) = New List(Of Item) From {
|
||||
New Item With {
|
||||
.Name = "+5 Dexterity Vest",
|
||||
.SellIn = 10,
|
||||
.Quality = 20
|
||||
},
|
||||
New Item With {
|
||||
.Name = "Aged Brie",
|
||||
.SellIn = 2,
|
||||
.Quality = 0
|
||||
},
|
||||
New Item With {
|
||||
.Name = "Elixir of the Mongoose",
|
||||
.SellIn = 5,
|
||||
.Quality = 7
|
||||
},
|
||||
New Item With {
|
||||
.Name = "Sulfuras, Hand of Ragnaros",
|
||||
.SellIn = 0,
|
||||
.Quality = 80
|
||||
},
|
||||
New Item With {
|
||||
.Name = "Sulfuras, Hand of Ragnaros",
|
||||
.SellIn = - 1,
|
||||
.Quality = 80
|
||||
},
|
||||
New Item With {
|
||||
.Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
.SellIn = 15,
|
||||
.Quality = 20
|
||||
},
|
||||
New Item With {
|
||||
.Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
.SellIn = 10,
|
||||
.Quality = 49
|
||||
},
|
||||
New Item With {
|
||||
.Name = "Backstage passes to a TAFKAL80ETC concert",
|
||||
.SellIn = 5,
|
||||
.Quality = 49
|
||||
},
|
||||
New Item With {
|
||||
.Name = "Conjured Mana Cake",
|
||||
.SellIn = 3,
|
||||
.Quality = 6
|
||||
}
|
||||
}
|
||||
Dim app = New GildedRose(Items)
|
||||
|
||||
For i = 0 To 31 - 1
|
||||
Console.WriteLine("-------- day " & i & " --------")
|
||||
Console.WriteLine("name, sellIn, quality")
|
||||
|
||||
For j = 0 To Items.Count - 1
|
||||
System.Console.WriteLine(Items(j))
|
||||
Next
|
||||
|
||||
Console.WriteLine("")
|
||||
app.UpdateQuality()
|
||||
Next
|
||||
End Sub
|
||||
End Module
|
||||
Reference in new issue
Block a user