private void checkButton_Click(object sender, EventArgs e) { LowCard cardLow = new LowCard(); MediumCard cardMed = new MediumCard(); HighCard cardHigh = new HighCard(); LowDoor doorLow = new LowDoor(); MediumDoor doorMed = new MediumDoor(); HighDoor doorHigh = new HighDoor(); if (cardLevelBox.SelectedIndex != -1 && doorLevelBox.SelectedIndex != -1) { string cardLevel = cardLevelBox.SelectedItem.ToString(); string doorLevel = doorLevelBox.SelectedItem.ToString(); bool validSecCheck = true; if (doorLevel == "Low") { if (cardLevel == "Low") { doorLow.Accept(cardLow); cardLow.Enter(doorLow); } else if (cardLevel == "Medium") { doorLow.Accept(cardMed); cardMed.Enter(doorLow); } else if (cardLevel == "High") { doorLow.Accept(cardHigh); cardHigh.Enter(doorLow); } } else if (cardLevel == "High") { if (doorLevel == "Medium") { doorMed.Accept(cardHigh); cardHigh.Enter(doorMed); } else if (doorLevel == "High") { doorHigh.Accept(cardHigh); cardHigh.Enter(doorHigh); } } else if (cardLevel == "Medium" && doorLevel == "Medium") { doorMed.Accept(cardMed); cardMed.Enter(doorMed); } else { /* * The following combinations do not compile: * doorHigh.Accept(cardMed); * cardMed.Enter(doorHigh); * * doorHigh.Accept(cardLow); * cardLow.Enter(doorHigh); * * doorMed.Accept(cardLow); * cardLow.Enter(doorMed); */ validSecCheck = false; } confirmMessage(cardLevel, doorLevel, validSecCheck); } }
public void Enter(MediumDoor door_med) { }