From 7ce7df7c7e1d037401f079626b82e0ba82caa849 Mon Sep 17 00:00:00 2001 From: Brad Collins Date: Thu, 28 Feb 2019 13:48:45 -0600 Subject: [PATCH 1/2] Added F# starter solution based on .NET Core --- .../GildedRose.ApprovalTests.fsproj | 33 ++ ...eTest.ApprovalTest.ThirtyDays.received.txt | 373 ++++++++++++++++++ fsharp-core/GildedRose.ApprovalTests/Tests.fs | 19 + .../GildedRose.UnitTests.fsproj | 31 ++ fsharp-core/GildedRose.UnitTests/Tests.fs | 14 + fsharp-core/GildedRose.sln | 37 ++ fsharp-core/GildedRose/GildedRose.fsproj | 16 + fsharp-core/GildedRose/Program.fs | 65 +++ 8 files changed, 588 insertions(+) create mode 100644 fsharp-core/GildedRose.ApprovalTests/GildedRose.ApprovalTests.fsproj create mode 100644 fsharp-core/GildedRose.ApprovalTests/GildedRoseTest.ApprovalTest.ThirtyDays.received.txt create mode 100644 fsharp-core/GildedRose.ApprovalTests/Tests.fs create mode 100644 fsharp-core/GildedRose.UnitTests/GildedRose.UnitTests.fsproj create mode 100644 fsharp-core/GildedRose.UnitTests/Tests.fs create mode 100644 fsharp-core/GildedRose.sln create mode 100644 fsharp-core/GildedRose/GildedRose.fsproj create mode 100644 fsharp-core/GildedRose/Program.fs diff --git a/fsharp-core/GildedRose.ApprovalTests/GildedRose.ApprovalTests.fsproj b/fsharp-core/GildedRose.ApprovalTests/GildedRose.ApprovalTests.fsproj new file mode 100644 index 00000000..2e96240b --- /dev/null +++ b/fsharp-core/GildedRose.ApprovalTests/GildedRose.ApprovalTests.fsproj @@ -0,0 +1,33 @@ + + + + netcoreapp2.1 + + false + + + + + Always + + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + + + + + diff --git a/fsharp-core/GildedRose.ApprovalTests/GildedRoseTest.ApprovalTest.ThirtyDays.received.txt b/fsharp-core/GildedRose.ApprovalTests/GildedRoseTest.ApprovalTest.ThirtyDays.received.txt new file mode 100644 index 00000000..cd66984f --- /dev/null +++ b/fsharp-core/GildedRose.ApprovalTests/GildedRoseTest.ApprovalTest.ThirtyDays.received.txt @@ -0,0 +1,373 @@ +OMGHAI! +-------- day 0 -------- +name, sellIn, quality ++5 Dexterity Vest, 10, 20 +Aged Brie, 2, 0 +Elixir of the Mongoose, 5, 7 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 15, 20 +Backstage passes to a TAFKAL80ETC concert, 10, 49 +Backstage passes to a TAFKAL80ETC concert, 5, 49 +Conjured Mana Cake, 3, 6 + +-------- day 1 -------- +name, sellIn, quality ++5 Dexterity Vest, 9, 19 +Aged Brie, 1, 1 +Elixir of the Mongoose, 4, 6 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 14, 21 +Backstage passes to a TAFKAL80ETC concert, 9, 50 +Backstage passes to a TAFKAL80ETC concert, 4, 50 +Conjured Mana Cake, 2, 5 + +-------- day 2 -------- +name, sellIn, quality ++5 Dexterity Vest, 8, 18 +Aged Brie, 0, 2 +Elixir of the Mongoose, 3, 5 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 13, 22 +Backstage passes to a TAFKAL80ETC concert, 8, 50 +Backstage passes to a TAFKAL80ETC concert, 3, 50 +Conjured Mana Cake, 1, 4 + +-------- day 3 -------- +name, sellIn, quality ++5 Dexterity Vest, 7, 17 +Aged Brie, -1, 4 +Elixir of the Mongoose, 2, 4 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 12, 23 +Backstage passes to a TAFKAL80ETC concert, 7, 50 +Backstage passes to a TAFKAL80ETC concert, 2, 50 +Conjured Mana Cake, 0, 3 + +-------- day 4 -------- +name, sellIn, quality ++5 Dexterity Vest, 6, 16 +Aged Brie, -2, 6 +Elixir of the Mongoose, 1, 3 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 11, 24 +Backstage passes to a TAFKAL80ETC concert, 6, 50 +Backstage passes to a TAFKAL80ETC concert, 1, 50 +Conjured Mana Cake, -1, 1 + +-------- day 5 -------- +name, sellIn, quality ++5 Dexterity Vest, 5, 15 +Aged Brie, -3, 8 +Elixir of the Mongoose, 0, 2 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 10, 25 +Backstage passes to a TAFKAL80ETC concert, 5, 50 +Backstage passes to a TAFKAL80ETC concert, 0, 50 +Conjured Mana Cake, -2, 0 + +-------- day 6 -------- +name, sellIn, quality ++5 Dexterity Vest, 4, 14 +Aged Brie, -4, 10 +Elixir of the Mongoose, -1, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 9, 27 +Backstage passes to a TAFKAL80ETC concert, 4, 50 +Backstage passes to a TAFKAL80ETC concert, -1, 0 +Conjured Mana Cake, -3, 0 + +-------- day 7 -------- +name, sellIn, quality ++5 Dexterity Vest, 3, 13 +Aged Brie, -5, 12 +Elixir of the Mongoose, -2, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 8, 29 +Backstage passes to a TAFKAL80ETC concert, 3, 50 +Backstage passes to a TAFKAL80ETC concert, -2, 0 +Conjured Mana Cake, -4, 0 + +-------- day 8 -------- +name, sellIn, quality ++5 Dexterity Vest, 2, 12 +Aged Brie, -6, 14 +Elixir of the Mongoose, -3, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 7, 31 +Backstage passes to a TAFKAL80ETC concert, 2, 50 +Backstage passes to a TAFKAL80ETC concert, -3, 0 +Conjured Mana Cake, -5, 0 + +-------- day 9 -------- +name, sellIn, quality ++5 Dexterity Vest, 1, 11 +Aged Brie, -7, 16 +Elixir of the Mongoose, -4, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 6, 33 +Backstage passes to a TAFKAL80ETC concert, 1, 50 +Backstage passes to a TAFKAL80ETC concert, -4, 0 +Conjured Mana Cake, -6, 0 + +-------- day 10 -------- +name, sellIn, quality ++5 Dexterity Vest, 0, 10 +Aged Brie, -8, 18 +Elixir of the Mongoose, -5, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 5, 35 +Backstage passes to a TAFKAL80ETC concert, 0, 50 +Backstage passes to a TAFKAL80ETC concert, -5, 0 +Conjured Mana Cake, -7, 0 + +-------- day 11 -------- +name, sellIn, quality ++5 Dexterity Vest, -1, 8 +Aged Brie, -9, 20 +Elixir of the Mongoose, -6, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 4, 38 +Backstage passes to a TAFKAL80ETC concert, -1, 0 +Backstage passes to a TAFKAL80ETC concert, -6, 0 +Conjured Mana Cake, -8, 0 + +-------- day 12 -------- +name, sellIn, quality ++5 Dexterity Vest, -2, 6 +Aged Brie, -10, 22 +Elixir of the Mongoose, -7, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 3, 41 +Backstage passes to a TAFKAL80ETC concert, -2, 0 +Backstage passes to a TAFKAL80ETC concert, -7, 0 +Conjured Mana Cake, -9, 0 + +-------- day 13 -------- +name, sellIn, quality ++5 Dexterity Vest, -3, 4 +Aged Brie, -11, 24 +Elixir of the Mongoose, -8, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 2, 44 +Backstage passes to a TAFKAL80ETC concert, -3, 0 +Backstage passes to a TAFKAL80ETC concert, -8, 0 +Conjured Mana Cake, -10, 0 + +-------- day 14 -------- +name, sellIn, quality ++5 Dexterity Vest, -4, 2 +Aged Brie, -12, 26 +Elixir of the Mongoose, -9, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 1, 47 +Backstage passes to a TAFKAL80ETC concert, -4, 0 +Backstage passes to a TAFKAL80ETC concert, -9, 0 +Conjured Mana Cake, -11, 0 + +-------- day 15 -------- +name, sellIn, quality ++5 Dexterity Vest, -5, 0 +Aged Brie, -13, 28 +Elixir of the Mongoose, -10, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, 0, 50 +Backstage passes to a TAFKAL80ETC concert, -5, 0 +Backstage passes to a TAFKAL80ETC concert, -10, 0 +Conjured Mana Cake, -12, 0 + +-------- day 16 -------- +name, sellIn, quality ++5 Dexterity Vest, -6, 0 +Aged Brie, -14, 30 +Elixir of the Mongoose, -11, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -1, 0 +Backstage passes to a TAFKAL80ETC concert, -6, 0 +Backstage passes to a TAFKAL80ETC concert, -11, 0 +Conjured Mana Cake, -13, 0 + +-------- day 17 -------- +name, sellIn, quality ++5 Dexterity Vest, -7, 0 +Aged Brie, -15, 32 +Elixir of the Mongoose, -12, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -2, 0 +Backstage passes to a TAFKAL80ETC concert, -7, 0 +Backstage passes to a TAFKAL80ETC concert, -12, 0 +Conjured Mana Cake, -14, 0 + +-------- day 18 -------- +name, sellIn, quality ++5 Dexterity Vest, -8, 0 +Aged Brie, -16, 34 +Elixir of the Mongoose, -13, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -3, 0 +Backstage passes to a TAFKAL80ETC concert, -8, 0 +Backstage passes to a TAFKAL80ETC concert, -13, 0 +Conjured Mana Cake, -15, 0 + +-------- day 19 -------- +name, sellIn, quality ++5 Dexterity Vest, -9, 0 +Aged Brie, -17, 36 +Elixir of the Mongoose, -14, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -4, 0 +Backstage passes to a TAFKAL80ETC concert, -9, 0 +Backstage passes to a TAFKAL80ETC concert, -14, 0 +Conjured Mana Cake, -16, 0 + +-------- day 20 -------- +name, sellIn, quality ++5 Dexterity Vest, -10, 0 +Aged Brie, -18, 38 +Elixir of the Mongoose, -15, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -5, 0 +Backstage passes to a TAFKAL80ETC concert, -10, 0 +Backstage passes to a TAFKAL80ETC concert, -15, 0 +Conjured Mana Cake, -17, 0 + +-------- day 21 -------- +name, sellIn, quality ++5 Dexterity Vest, -11, 0 +Aged Brie, -19, 40 +Elixir of the Mongoose, -16, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -6, 0 +Backstage passes to a TAFKAL80ETC concert, -11, 0 +Backstage passes to a TAFKAL80ETC concert, -16, 0 +Conjured Mana Cake, -18, 0 + +-------- day 22 -------- +name, sellIn, quality ++5 Dexterity Vest, -12, 0 +Aged Brie, -20, 42 +Elixir of the Mongoose, -17, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -7, 0 +Backstage passes to a TAFKAL80ETC concert, -12, 0 +Backstage passes to a TAFKAL80ETC concert, -17, 0 +Conjured Mana Cake, -19, 0 + +-------- day 23 -------- +name, sellIn, quality ++5 Dexterity Vest, -13, 0 +Aged Brie, -21, 44 +Elixir of the Mongoose, -18, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -8, 0 +Backstage passes to a TAFKAL80ETC concert, -13, 0 +Backstage passes to a TAFKAL80ETC concert, -18, 0 +Conjured Mana Cake, -20, 0 + +-------- day 24 -------- +name, sellIn, quality ++5 Dexterity Vest, -14, 0 +Aged Brie, -22, 46 +Elixir of the Mongoose, -19, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -9, 0 +Backstage passes to a TAFKAL80ETC concert, -14, 0 +Backstage passes to a TAFKAL80ETC concert, -19, 0 +Conjured Mana Cake, -21, 0 + +-------- day 25 -------- +name, sellIn, quality ++5 Dexterity Vest, -15, 0 +Aged Brie, -23, 48 +Elixir of the Mongoose, -20, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -10, 0 +Backstage passes to a TAFKAL80ETC concert, -15, 0 +Backstage passes to a TAFKAL80ETC concert, -20, 0 +Conjured Mana Cake, -22, 0 + +-------- day 26 -------- +name, sellIn, quality ++5 Dexterity Vest, -16, 0 +Aged Brie, -24, 50 +Elixir of the Mongoose, -21, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -11, 0 +Backstage passes to a TAFKAL80ETC concert, -16, 0 +Backstage passes to a TAFKAL80ETC concert, -21, 0 +Conjured Mana Cake, -23, 0 + +-------- day 27 -------- +name, sellIn, quality ++5 Dexterity Vest, -17, 0 +Aged Brie, -25, 50 +Elixir of the Mongoose, -22, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -12, 0 +Backstage passes to a TAFKAL80ETC concert, -17, 0 +Backstage passes to a TAFKAL80ETC concert, -22, 0 +Conjured Mana Cake, -24, 0 + +-------- day 28 -------- +name, sellIn, quality ++5 Dexterity Vest, -18, 0 +Aged Brie, -26, 50 +Elixir of the Mongoose, -23, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -13, 0 +Backstage passes to a TAFKAL80ETC concert, -18, 0 +Backstage passes to a TAFKAL80ETC concert, -23, 0 +Conjured Mana Cake, -25, 0 + +-------- day 29 -------- +name, sellIn, quality ++5 Dexterity Vest, -19, 0 +Aged Brie, -27, 50 +Elixir of the Mongoose, -24, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -14, 0 +Backstage passes to a TAFKAL80ETC concert, -19, 0 +Backstage passes to a TAFKAL80ETC concert, -24, 0 +Conjured Mana Cake, -26, 0 + +-------- day 30 -------- +name, sellIn, quality ++5 Dexterity Vest, -20, 0 +Aged Brie, -28, 50 +Elixir of the Mongoose, -25, 0 +Sulfuras, Hand of Ragnaros, 0, 80 +Sulfuras, Hand of Ragnaros, -1, 80 +Backstage passes to a TAFKAL80ETC concert, -15, 0 +Backstage passes to a TAFKAL80ETC concert, -20, 0 +Backstage passes to a TAFKAL80ETC concert, -25, 0 +Conjured Mana Cake, -27, 0 + diff --git a/fsharp-core/GildedRose.ApprovalTests/Tests.fs b/fsharp-core/GildedRose.ApprovalTests/Tests.fs new file mode 100644 index 00000000..06709445 --- /dev/null +++ b/fsharp-core/GildedRose.ApprovalTests/Tests.fs @@ -0,0 +1,19 @@ +module GildedRose.ApprovalTests + +open System +open Xunit +open System.Text +open System.IO + +[] +let ``Thirty day report is correct`` () = + let expected = File.ReadAllText "GildedRoseTest.ApprovalTest.ThirtyDays.received.txt" + + let fakeoutput = new StringBuilder() + Console.SetOut(new StringWriter(fakeoutput)) + Console.SetIn(new StringReader("a\n")) + + GildedRose.Program.main [||] |> ignore + let actual = fakeoutput.ToString() + + Assert.Equal(expected, actual) diff --git a/fsharp-core/GildedRose.UnitTests/GildedRose.UnitTests.fsproj b/fsharp-core/GildedRose.UnitTests/GildedRose.UnitTests.fsproj new file mode 100644 index 00000000..e75af14b --- /dev/null +++ b/fsharp-core/GildedRose.UnitTests/GildedRose.UnitTests.fsproj @@ -0,0 +1,31 @@ + + + + netcoreapp2.1 + + false + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + + + + + + + + + + diff --git a/fsharp-core/GildedRose.UnitTests/Tests.fs b/fsharp-core/GildedRose.UnitTests/Tests.fs new file mode 100644 index 00000000..c2f88505 --- /dev/null +++ b/fsharp-core/GildedRose.UnitTests/Tests.fs @@ -0,0 +1,14 @@ +module GildedRose.UnitTests + +open GildedRose +open System.Collections.Generic +open Xunit +open Swensen.Unquote + +[] +let ``My test`` () = + let Items = new List() + Items.Add({Name = "foo"; SellIn = 0; Quality = 0}) + let app = new GildedRose(Items) + app.UpdateQuality() + test <@ "fixme" = Items.[0].Name @> \ No newline at end of file diff --git a/fsharp-core/GildedRose.sln b/fsharp-core/GildedRose.sln new file mode 100644 index 00000000..801ef9b1 --- /dev/null +++ b/fsharp-core/GildedRose.sln @@ -0,0 +1,37 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.421 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GildedRose", "GildedRose\GildedRose.fsproj", "{63814E28-6A6A-4496-BD16-DC1DFD79CDC8}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GildedRose.UnitTests", "GildedRose.UnitTests\GildedRose.UnitTests.fsproj", "{34C47A43-9A27-44C0-9CA8-15324A76FD20}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GildedRose.ApprovalTests", "GildedRose.ApprovalTests\GildedRose.ApprovalTests.fsproj", "{C2C723A1-31CF-445C-BC8B-3CFC8620C8EB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {63814E28-6A6A-4496-BD16-DC1DFD79CDC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63814E28-6A6A-4496-BD16-DC1DFD79CDC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63814E28-6A6A-4496-BD16-DC1DFD79CDC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63814E28-6A6A-4496-BD16-DC1DFD79CDC8}.Release|Any CPU.Build.0 = Release|Any CPU + {34C47A43-9A27-44C0-9CA8-15324A76FD20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {34C47A43-9A27-44C0-9CA8-15324A76FD20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {34C47A43-9A27-44C0-9CA8-15324A76FD20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {34C47A43-9A27-44C0-9CA8-15324A76FD20}.Release|Any CPU.Build.0 = Release|Any CPU + {C2C723A1-31CF-445C-BC8B-3CFC8620C8EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2C723A1-31CF-445C-BC8B-3CFC8620C8EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2C723A1-31CF-445C-BC8B-3CFC8620C8EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2C723A1-31CF-445C-BC8B-3CFC8620C8EB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {16C52833-8AA9-469D-88D2-A3C9249ED08F} + EndGlobalSection +EndGlobal diff --git a/fsharp-core/GildedRose/GildedRose.fsproj b/fsharp-core/GildedRose/GildedRose.fsproj new file mode 100644 index 00000000..ae1a8c70 --- /dev/null +++ b/fsharp-core/GildedRose/GildedRose.fsproj @@ -0,0 +1,16 @@ + + + + Exe + netcoreapp2.1 + + + + + + + + + + + diff --git a/fsharp-core/GildedRose/Program.fs b/fsharp-core/GildedRose/Program.fs new file mode 100644 index 00000000..a5adc97e --- /dev/null +++ b/fsharp-core/GildedRose/Program.fs @@ -0,0 +1,65 @@ +namespace GildedRose + +open System.Collections.Generic + +type Item = { Name: string; SellIn: int; Quality: int } + +type GildedRose(items:IList) = + let Items = items + + member this.UpdateQuality() = + for i = 0 to Items.Count - 1 do + if Items.[i].Name <> "Aged Brie" && 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] <- { Items.[i] with Quality = (Items.[i].Quality - 1) } + else + if Items.[i].Quality < 50 then + Items.[i] <- { Items.[i] with 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] <- { Items.[i] with Quality = (Items.[i].Quality + 1) } + if Items.[i].SellIn < 6 then + if Items.[i].Quality < 50 then + Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality + 1) } + if Items.[i].Name <> "Sulfuras, Hand of Ragnaros" then + Items.[i] <- { Items.[i] with SellIn = (Items.[i].SellIn - 1) } + 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] <- { Items.[i] with Quality = (Items.[i].Quality - 1) } + else + Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality - Items.[i].Quality) } + else + if Items.[i].Quality < 50 then + Items.[i] <- { Items.[i] with Quality = (Items.[i].Quality + 1) } + () + + +module Program = + [] + let main argv = + printfn "OMGHAI!" + let Items = new List() + Items.Add({Name = "+5 Dexterity Vest"; SellIn = 10; Quality = 20}) + Items.Add({Name = "Aged Brie"; SellIn = 2; Quality = 0}) + Items.Add({Name = "Elixir of the Mongoose"; SellIn = 5; Quality = 7}) + Items.Add({Name = "Sulfuras, Hand of Ragnaros"; SellIn = 0; Quality = 80}) + Items.Add({Name = "Sulfuras, Hand of Ragnaros"; SellIn = -1; Quality = 80}) + Items.Add({Name = "Backstage passes to a TAFKAL80ETC concert"; SellIn = 15; Quality = 20}) + Items.Add({Name = "Backstage passes to a TAFKAL80ETC concert"; SellIn = 10; Quality = 49}) + Items.Add({Name = "Backstage passes to a TAFKAL80ETC concert"; SellIn = 5; Quality = 49}) + Items.Add({Name = "Conjured Mana Cake"; SellIn = 3; Quality = 6}) + + let app = new GildedRose(Items) + for i = 0 to 30 do + printfn "-------- day %d --------" i + printfn "name, sellIn, quality" + for j = 0 to Items.Count - 1 do + printfn "%s, %d, %d" Items.[j].Name Items.[j].SellIn Items.[j].Quality + printfn "" + app.UpdateQuality() + 0 \ No newline at end of file From 203551dadc78ea94c2bfd96e50626a6b5a9b4539 Mon Sep 17 00:00:00 2001 From: Brad Collins Date: Thu, 28 Feb 2019 13:51:02 -0600 Subject: [PATCH 2/2] Added .gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..42abe190 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin +obj +*.sln.DotSettings.user +.vs