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;
- namespace BubbleIceCream
- {
- public struct Players
- {
- public string firstname;
- public string lastname;
- public string interest;
- public int points;
- }
- class Program
- {
- public static int playercount = 43;
- static void Main()
- {
- Players[] player = new Players[playercount];
- Load(player);
- Sort(player);
- }
- public static void Load(Players[] player)
- {
- StreamReader sr = new StreamReader(@"C:\Users\thomcs4\OneDrive - Otago Polytechnic\BITY1\IN510 Programming 1\FamilyFeud\familyFeud.txt");
- for (int i = 0; i < playercount; i++)
- {
- player[i].firstname = sr.ReadLine();
- player[i].lastname = sr.ReadLine();
- player[i].interest = sr.ReadLine();
- player[i].points = 0;
- }
- Console.WriteLine("Playerdata has loaded.");
- Console.ReadLine();
- }
- public static void Sort(Players[] player)
- {
- Players temp;
- for (int i = 0; i < player.Length - 1; i++)
- {
- for (int pos = 0; pos < player.Length - 1; pos++)
- {
- if (player[pos + 1].firstname.CompareTo(player[pos].firstname) < 0)
- {
- temp = player[pos + 1];
- player[pos + 1] = player[pos];
- player[pos] = temp;
- }
- }
- }
- for (int i = 0; i < playercount; i++)
- {
- Console.WriteLine($"{player[i].firstname.PadRight(20)} {player[i].lastname.PadRight(20)}");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement