所以今天我看到了这个问题。 Bankteller console application
而且我想我会试着去做,因为这是一个常见的问题。 我已经得到了某种工作输出,但它没有像我预期的那样格式化。
这是我更新的代码:
客户类:
class Customer
{
private string name;
private int checkOutTime;
public Customer()
{
name = "john";
checkOutTime = 500;
}
public Customer(string name, int checkOutTime)
{
this.name = name;
this.checkOutTime = checkOutTime;
}
}
注册课程:
class Register
{
public Customer[] customers = new Customer[100];
public string[] names = { "jan", "peter", "hans", "karel", "tim", "rick", "Lewbert", "borat", "Sharkisha", "Bobo" };
public Random rnd = new Random();
public Queue<Customer> Line = new Queue<Customer>();
public Register(int amount, Register[] r, int id)
{
for (int i = 0; i < amount; i++)
{
customers[i] = new Customer(names[rnd.Next(0, 8)], rnd.Next(900, 5000));
Line.Enqueue(customers[i]);
if (Line.Count % 4 == 0)
{
id++;
amount = amount - 4;
r[id] = new Register(amount, r, id);
}
}
}
}
计划cs:
class Program
{
static void Main(string[] args)
{
Register[] bankRegisters = new Register[10];
Register r = new Register(12, bankRegisters, 0);
}
}
我得到的输出是嵌套的。它表明我的寄存器中有一个寄存器,而不是银行中的多个寄存器。
有人能指出我正确的方向。