TonyTroev

Gandalf

Feb 5th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _09_FoodFactory
  8. {
  9.     class FoodFactory
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             List<string> input = Console.ReadLine().Split(' ').ToList();
  14.  
  15.             Console.WriteLine(Mood.CalculateMood(Food.CalculatePoints(input)));
  16.         }
  17.     }
  18.  
  19.     public static class Food
  20.     {
  21.         public static int CalculatePoints(List<string> food)
  22.         {
  23.             int sum = 0;
  24.  
  25.             foreach (string word in food)
  26.             {
  27.                 switch (word.ToLower())
  28.                 {
  29.                     case "cram":
  30.                         sum += 2;
  31.                         break;
  32.                     case "lembas":
  33.                         sum += 3;
  34.                         break;
  35.                     case "apple":
  36.                     case "melon":
  37.                         sum++;
  38.                         break;
  39.                     case "honeycake":
  40.                         sum += 5;
  41.                         break;
  42.                     case "mushrooms":
  43.                         sum -= 10;
  44.                         break;
  45.                     default:
  46.                         sum--;
  47.                         break;
  48.                 }
  49.             }
  50.  
  51.             return sum;
  52.         }
  53.     }
  54.  
  55.     static class Mood
  56.     {
  57.         public static string CalculateMood(int points)
  58.         {
  59.             string mood = string.Empty;
  60.             if (points < -5)
  61.             {
  62.                 mood = "Angry";
  63.             }
  64.             else if (points <= 0)
  65.             {
  66.                 mood = "Sad";
  67.             }
  68.             else if (points <= 15)
  69.             {
  70.                 mood = "Happy";
  71.             }
  72.             else
  73.             {
  74.                 mood = "JavaScript";
  75.             }
  76.  
  77.             return mood;
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment