Advertisement
Guest User

Untitled

a guest
Feb 28th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.73 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. using System.IO;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace ConsoleApplication3
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             string location = @"C:\Users\Ryan\Desktop\chaz\log.txt";
  16.             string location2 = @"C:\Users\Ryan\Desktop\chaz\loot.txt";
  17.  
  18.             //Makeshift menu with user input
  19.             Console.WriteLine("*****************");
  20.             Console.WriteLine("Menu:");
  21.             Console.WriteLine();
  22.             Console.WriteLine("1 - Attendance Report");
  23.             Console.WriteLine("2 - Loot distributed");
  24.             Console.WriteLine("3 - Add Attendance Issue");
  25.             Console.WriteLine("4 - Add loot gain");
  26.             Console.WriteLine("5 - List all attendance");
  27.             Console.WriteLine("6 - List all loot");
  28.             Console.WriteLine("*****************");
  29.             char input = Console.ReadLine()[0];
  30.             Console.WriteLine();
  31.  
  32.             //Choice selection
  33.             if (input == '1')
  34.                 attendanceReport(location);
  35.             else if (input == '2')
  36.                 lootDistributed(location2);
  37.             else if (input == '3')
  38.                 attendanceIssue(location);
  39.             else if (input == '4')
  40.                 lootGained(location2);
  41.             else if (input == '5')
  42.                 listAttendance(location);
  43.             else if (input == '6')
  44.                 listLoot(location2);
  45.             else
  46.                 Console.WriteLine("You have entered an incorrect key.");
  47.         }
  48.         public static void attendanceReport(string location)
  49.         {
  50.             Console.Write("Enter player name: ");
  51.             string playerName = Console.ReadLine();
  52.  
  53.             //read the file and store each line in array
  54.             string[] text = System.IO.File.ReadAllLines(location);
  55.             string textString = System.IO.File.ReadAllText(location);
  56.  
  57.             //scan file for name and print contents
  58.             using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
  59.             {
  60.                 foreach (string line in text)
  61.                 {
  62.                     if (line.Contains(playerName))
  63.                         Console.WriteLine(line);
  64.                 }
  65.             }
  66.             if (!textString.Contains(playerName))
  67.             {
  68.                 Console.WriteLine(playerName + " has no record for attendance.");
  69.             }
  70.  
  71.         }
  72.         public static void lootDistributed(string location)
  73.         {
  74.             Console.Write("Enter player name: ");
  75.             string playerName = Console.ReadLine();
  76.  
  77.             //read the file and store each line in array
  78.             string[] text = System.IO.File.ReadAllLines(location);
  79.             string textString = System.IO.File.ReadAllText(location);
  80.  
  81.             //scan file for name and print contents
  82.             using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
  83.             {
  84.                 foreach (string line in text)
  85.                 {
  86.                     if (line.Contains(playerName))
  87.                         Console.WriteLine(line);
  88.                 }
  89.             }
  90.             if (!textString.Contains(playerName))
  91.             {
  92.                 Console.WriteLine(playerName + " has not gained any items.");
  93.             }
  94.         }
  95.         public static void attendanceIssue(string location)
  96.         {
  97.             Console.Write("Enter player name: ");
  98.             string playerName = Console.ReadLine();
  99.  
  100.             Console.Write("Enter date: ");
  101.             string date = Console.ReadLine();
  102.  
  103.             Console.Write("Enter issue: ");
  104.             string param = Console.ReadLine();
  105.  
  106.             //read the file and store each line in array
  107.             string[] text = System.IO.File.ReadAllLines(location);
  108.             string textString = System.IO.File.ReadAllText(location);
  109.  
  110.             if (!textString.Contains(playerName))
  111.             {
  112.                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
  113.                     file.WriteLine("On " + date + " " + playerName + " was " + param);
  114.                 Console.WriteLine(playerName + " had no record and was added to the database.");
  115.             }
  116.             else if (textString.Contains(playerName))
  117.             {
  118.                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
  119.                     file.WriteLine("On " + date + " " + playerName + " was " + param);
  120.                 Console.WriteLine("Incident recorded");
  121.             }
  122.         }
  123.         public static void lootGained(string location)
  124.         {
  125.             Console.Write("Enter player name: ");
  126.             string playerName = Console.ReadLine();
  127.  
  128.             Console.Write("Enter date: ");
  129.             string date = Console.ReadLine();
  130.  
  131.             Console.Write("Enter loot gained: ");
  132.             string param = Console.ReadLine();
  133.  
  134.             //read the file and store each line in array
  135.             string[] text = System.IO.File.ReadAllLines(location);
  136.             string textString = System.IO.File.ReadAllText(location);
  137.  
  138.             if (!textString.Contains(playerName))
  139.             {
  140.                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
  141.                     file.WriteLine("On " + date + " " + playerName + " recieved " + param);
  142.                 Console.WriteLine(playerName + " had no record and was added to the database.");
  143.             }
  144.             else if (textString.Contains(playerName))
  145.             {
  146.                 using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
  147.                     file.WriteLine("On " + date + " " + playerName + " recieved " + param);
  148.                 Console.WriteLine("Loot gain recorded");
  149.             }
  150.         }
  151.         public static void listAttendance(string location)
  152.         {
  153.             string[] text = System.IO.File.ReadAllLines(location);
  154.  
  155.             using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
  156.             {
  157.                 foreach (string line in text)
  158.                 {
  159.                         Console.WriteLine(line);
  160.                 }
  161.             }
  162.         }
  163.         public static void listLoot(string location)
  164.         {
  165.             string[] text = System.IO.File.ReadAllLines(location);
  166.  
  167.             using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
  168.             {
  169.                 foreach (string line in text)
  170.                 {
  171.                     Console.WriteLine(line);
  172.                 }
  173.             }
  174.         }
  175.     }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement