module window(reset,out1,out10,light,switch,finish);
input reset;
input [7:0] switch;

//display need to declear as output and wire
output [6:0]out1;
output [6:0]out10;
output [7:0]light;
output finish;

wire [6:0]out1;
wire [6:0]out10;
//

//logic counter neeed to declear as reg
reg [7:0]tries;
reg [7:0]light;
reg [3:0] i;
reg finish;
//

displayNumber DISNUM (.in(tries),.out10(out10),.out1(out1));

always@(reset)
begin
    if(reset)
    begin
        tries<=8'd0;
        finish<=1'b0;
        i=($random)%8;
        light=8'b00000000;
        light[i]=1'b1;
    end
end

always@(switch)
begin
    for(i=4'd0;i<4'd8;i++)
    begin
        if(switch[i]==1'b1)
        begin
            if(i>=1) light[i-4'd1]=~light[i-1];
            if(i<=6) light[i+1]=~light[i+1];
            light[i]=~light[i];
            tries<=tries+1'd1;
        end
    end
    if(light==8'b00000000) finish=1'b1;
end

endmodule