mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
cargo fmt
Standard Rust formatting practice
This commit is contained in:
parent
fbe24e35b5
commit
a699803ce7
@ -4,17 +4,21 @@ use std::vec;
|
||||
pub struct Item {
|
||||
pub name: string::String,
|
||||
pub sell_in: i32,
|
||||
pub quality: i32
|
||||
pub quality: i32,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn new(name: String, sell_in: i32, quality: i32) -> Item {
|
||||
Item {name: name, sell_in: sell_in, quality: quality}
|
||||
Item {
|
||||
name: name,
|
||||
sell_in: sell_in,
|
||||
quality: quality,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GildedRose {
|
||||
pub items: vec::Vec<Item>
|
||||
pub items: vec::Vec<Item>,
|
||||
}
|
||||
|
||||
impl GildedRose {
|
||||
@ -24,15 +28,15 @@ impl GildedRose {
|
||||
|
||||
pub fn update_quality(&mut self) {
|
||||
for item in &mut self.items {
|
||||
if item.name != "Aged Brie" && item.name != "Backstage passes to a TAFKAL80ETC concert" {
|
||||
if item.name != "Aged Brie" && item.name != "Backstage passes to a TAFKAL80ETC concert"
|
||||
{
|
||||
if item.quality > 0 {
|
||||
if item.name != "Sulfuras, Hand of Ragnaros" {
|
||||
item.quality = item.quality - 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if item.quality < 50
|
||||
{
|
||||
if item.quality < 50 {
|
||||
item.quality = item.quality + 1;
|
||||
|
||||
if item.name == "Backstage passes to a TAFKAL80ETC concert" {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use super::{Item, GildedRose};
|
||||
use super::{GildedRose, Item};
|
||||
|
||||
#[test]
|
||||
pub fn foo() {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
|
||||
mod gildedrose;
|
||||
|
||||
use gildedrose::{Item, GildedRose};
|
||||
use gildedrose::{GildedRose, Item};
|
||||
|
||||
fn main() {
|
||||
let items = vec![
|
||||
@ -10,11 +9,23 @@ fn main() {
|
||||
Item::new(String::from("Elixir of the Mongoose"), 5, 7),
|
||||
Item::new(String::from("Sulfuras, Hand of Ragnaros"), 0, 80),
|
||||
Item::new(String::from("Sulfuras, Hand of Ragnaros"), -1, 80),
|
||||
Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 15, 20),
|
||||
Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 10, 49),
|
||||
Item::new(String::from("Backstage passes to a TAFKAL80ETC concert"), 5, 49),
|
||||
Item::new(
|
||||
String::from("Backstage passes to a TAFKAL80ETC concert"),
|
||||
15,
|
||||
20,
|
||||
),
|
||||
Item::new(
|
||||
String::from("Backstage passes to a TAFKAL80ETC concert"),
|
||||
10,
|
||||
49,
|
||||
),
|
||||
Item::new(
|
||||
String::from("Backstage passes to a TAFKAL80ETC concert"),
|
||||
5,
|
||||
49,
|
||||
),
|
||||
// this conjured item does not work properly yet
|
||||
Item::new(String::from("Conjured Mana Cake"), 3, 6)
|
||||
Item::new(String::from("Conjured Mana Cake"), 3, 6),
|
||||
];
|
||||
let mut rose = GildedRose::new(items);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user