编辑代码

using System;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        Student stu = new Student();
        while(true){
            stu.IsChosen(stu.GetRandomLineNumber(),stu.GetRandomCollNumber());
            if (stu.FullyChosen()) { stu.InitDict(); }
            Console.ReadLine();
        }
    }
}

public class Student
{
    public Dictionary<(int, int), bool> stuDic;
    private static int maxLN = 8;
    private static int maxCN = 4;

    public Student()
    {
        stuDic = new Dictionary<(int, int), bool>();
        InitDict();
    }

    public void InitDict()
    {
        for (int i = 1; i <= maxLN; i++)
        {
            for (int j = 1; j <= maxCN; j++)
            {
                if (j == maxCN && (i == 3 || i == 4 || i == 8))
                {
                    continue;
                }
                var key = (i,j);
                if (!this.stuDic.ContainsKey(key))
                {
                    this.stuDic.Add(key, false);
                }
            }
        }
    }

    public void IsChosen(int i, int j)
    {
        this.stuDic[(i, j)] = true;
        System.Console.WriteLine("{0}-{1}",i,j);
    }

    public bool FullyChosen()
    {
        foreach (bool value in this.stuDic.Values)
        {
            if (value)
            {
                return true;
            }
        }
        return false;
    }

    public int GetRandomLineNumber()
    {
        Random rand = new Random();
        return rand.Next(1, 8);
    }

    public int GetRandomCollNumber()
    {
        Random rand = new Random();
        return rand.Next(1, 4);
    }
}