Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Gandalfs_Stash
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- class GandalfsStash
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> foodTypes = new Dictionary<string, int>();
- foodTypes["apple"] = 1;
- foodTypes["cram"] = 2;
- foodTypes["honeycake"] = 5;
- foodTypes["lembas"] = 3;
- foodTypes["melon"] = 1;
- foodTypes["mushrooms"] = -10;
- int hapiness = int.Parse(Console.ReadLine());
- string foodStr = Console.ReadLine().ToLower();
- string pattern = @"[^A-Za-z]+";
- string[] foods = Regex.Split(foodStr, pattern)
- .Where(s => !string.IsNullOrEmpty(s)).ToArray();
- foreach (string food in foods)
- {
- if (foodTypes.ContainsKey(food))
- {
- hapiness += foodTypes[food];
- }
- else
- {
- hapiness--;
- }
- }
- Console.WriteLine(hapiness);
- string mood = "Angry";
- if (hapiness >= -5 && hapiness < 0)
- {
- mood = "Sad";
- }
- else if (hapiness > 0 && hapiness <= 15)
- {
- mood = "Happy";
- }
- else if (hapiness > 15)
- {
- mood = "Special JavaScript mood";
- }
- Console.WriteLine(mood);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement