Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Text.RegularExpressions;
- namespace ConsoleApplication3
- {
- class Program
- {
- static void Main(string[] args)
- {
- string location = @"C:\Users\Ryan\Desktop\chaz\log.txt";
- string location2 = @"C:\Users\Ryan\Desktop\chaz\loot.txt";
- //Makeshift menu with user input
- Console.WriteLine("*****************");
- Console.WriteLine("Menu:");
- Console.WriteLine();
- Console.WriteLine("1 - Attendance Report");
- Console.WriteLine("2 - Loot distributed");
- Console.WriteLine("3 - Add Attendance Issue");
- Console.WriteLine("4 - Add loot gain");
- Console.WriteLine("5 - List all attendance");
- Console.WriteLine("6 - List all loot");
- Console.WriteLine("*****************");
- char input = Console.ReadLine()[0];
- Console.WriteLine();
- //Choice selection
- if (input == '1')
- attendanceReport(location);
- else if (input == '2')
- lootDistributed(location2);
- else if (input == '3')
- attendanceIssue(location);
- else if (input == '4')
- lootGained(location2);
- else if (input == '5')
- listAttendance(location);
- else if (input == '6')
- listLoot(location2);
- else
- Console.WriteLine("You have entered an incorrect key.");
- }
- public static void attendanceReport(string location)
- {
- Console.Write("Enter player name: ");
- string playerName = Console.ReadLine();
- //read the file and store each line in array
- string[] text = System.IO.File.ReadAllLines(location);
- string textString = System.IO.File.ReadAllText(location);
- //scan file for name and print contents
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
- {
- foreach (string line in text)
- {
- if (line.Contains(playerName))
- Console.WriteLine(line);
- }
- }
- if (!textString.Contains(playerName))
- {
- Console.WriteLine(playerName + " has no record for attendance.");
- }
- }
- public static void lootDistributed(string location)
- {
- Console.Write("Enter player name: ");
- string playerName = Console.ReadLine();
- //read the file and store each line in array
- string[] text = System.IO.File.ReadAllLines(location);
- string textString = System.IO.File.ReadAllText(location);
- //scan file for name and print contents
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
- {
- foreach (string line in text)
- {
- if (line.Contains(playerName))
- Console.WriteLine(line);
- }
- }
- if (!textString.Contains(playerName))
- {
- Console.WriteLine(playerName + " has not gained any items.");
- }
- }
- public static void attendanceIssue(string location)
- {
- Console.Write("Enter player name: ");
- string playerName = Console.ReadLine();
- Console.Write("Enter date: ");
- string date = Console.ReadLine();
- Console.Write("Enter issue: ");
- string param = Console.ReadLine();
- //read the file and store each line in array
- string[] text = System.IO.File.ReadAllLines(location);
- string textString = System.IO.File.ReadAllText(location);
- if (!textString.Contains(playerName))
- {
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
- file.WriteLine("On " + date + " " + playerName + " was " + param);
- Console.WriteLine(playerName + " had no record and was added to the database.");
- }
- else if (textString.Contains(playerName))
- {
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
- file.WriteLine("On " + date + " " + playerName + " was " + param);
- Console.WriteLine("Incident recorded");
- }
- }
- public static void lootGained(string location)
- {
- Console.Write("Enter player name: ");
- string playerName = Console.ReadLine();
- Console.Write("Enter date: ");
- string date = Console.ReadLine();
- Console.Write("Enter loot gained: ");
- string param = Console.ReadLine();
- //read the file and store each line in array
- string[] text = System.IO.File.ReadAllLines(location);
- string textString = System.IO.File.ReadAllText(location);
- if (!textString.Contains(playerName))
- {
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
- file.WriteLine("On " + date + " " + playerName + " recieved " + param);
- Console.WriteLine(playerName + " had no record and was added to the database.");
- }
- else if (textString.Contains(playerName))
- {
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
- file.WriteLine("On " + date + " " + playerName + " recieved " + param);
- Console.WriteLine("Loot gain recorded");
- }
- }
- public static void listAttendance(string location)
- {
- string[] text = System.IO.File.ReadAllLines(location);
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
- {
- foreach (string line in text)
- {
- Console.WriteLine(line);
- }
- }
- }
- public static void listLoot(string location)
- {
- string[] text = System.IO.File.ReadAllLines(location);
- using (System.IO.StreamWriter file = new System.IO.StreamWriter(location, true))
- {
- foreach (string line in text)
- {
- Console.WriteLine(line);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement