GildedRose-Refactoring-Kata/cpp/src/GildedRose.cc
Jacob Mossberg 1836cca836 Refactor C++ version of the Gilded Rose kata
* Make it possible to build and run tests in CLion
  and Visual Studio 2019 out of the box

* Provide four types of initial test using different test frameworks:
  * Catch2 test framework
    * Traditional unit testing using Catch2
    * Approval test using Catch2
  * Google Test test framework
    * Traditional unit testing using Google Test
    * Approval test using Google Test

* The different types of initial test are located in separate folders
  in the test folder.

* Remove scripts to build and run tests and replace
  with instructions in the cpp README.md

* Use C++17

* Use CMake => 3.13
2019-12-09 08:40:47 +01:00

81 lines
2.3 KiB
C++

#include "GildedRose.h"
GildedRose::GildedRose(vector<Item> & items) : items(items)
{}
void GildedRose::updateQuality()
{
for (int i = 0; i < items.size(); i++)
{
if (items[i].name != "Aged Brie" && items[i].name != "Backstage passes to a TAFKAL80ETC concert")
{
if (items[i].quality > 0)
{
if (items[i].name != "Sulfuras, Hand of Ragnaros")
{
items[i].quality = items[i].quality - 1;
}
}
}
else
{
if (items[i].quality < 50)
{
items[i].quality = items[i].quality + 1;
if (items[i].name == "Backstage passes to a TAFKAL80ETC concert")
{
if (items[i].sellIn < 11)
{
if (items[i].quality < 50)
{
items[i].quality = items[i].quality + 1;
}
}
if (items[i].sellIn < 6)
{
if (items[i].quality < 50)
{
items[i].quality = items[i].quality + 1;
}
}
}
}
}
if (items[i].name != "Sulfuras, Hand of Ragnaros")
{
items[i].sellIn = items[i].sellIn - 1;
}
if (items[i].sellIn < 0)
{
if (items[i].name != "Aged Brie")
{
if (items[i].name != "Backstage passes to a TAFKAL80ETC concert")
{
if (items[i].quality > 0)
{
if (items[i].name != "Sulfuras, Hand of Ragnaros")
{
items[i].quality = items[i].quality - 1;
}
}
}
else
{
items[i].quality = items[i].quality - items[i].quality;
}
}
else
{
if (items[i].quality < 50)
{
items[i].quality = items[i].quality + 1;
}
}
}
}
}