static void Main(string[] args) { // Do not mind the red-underline, these classes need to be implemented by you StreetFighter mess = new StreetFighter(120, 2, 1, 7); ProFighter ryu = new ProFighter(150, 4, 2, 13); RockStarFighter blanka = new RockStarFighter(170, 5, 4, 17); ryu.DoBoxing(blanka); mess.DoStreet(blanka); blanka.DoBoxing(ryu); blanka.DoMuayThai(ryu); blanka.DoStreet(mess); Console.ReadLine(); }
static void Main(string[] args) { StreetFighter mess = new StreetFighter(120, 2, 1, 7); ProFighter ryu = new ProFighter(150, 4, 2, 13); RockstarFighter blanka = new RockstarFighter(170, 5, 4, 17); ryu.DoBoxing(mess); mess.DoStreet(ryu); blanka.DoMuayThai(ryu); Console.ReadLine(); }
static void Main(string[] args) { StreetFighter mess = new StreetFighter("Mumin", 120, 2, 1, 7); ProFighter ryu = new ProFighter("Bojka", 150, 4, 2, 13); RockstarFighter blanka = new RockstarFighter("Blanka", 170, 5, 4, 17); Console.WriteLine($"{ryu.Name} vs {blanka.Name}"); while (true) { ryu.DoBoxing(blanka); if (blanka.GetHealth() == 0) { break; } Thread.Sleep(300); blanka.DoBoxing(ryu); if (ryu.GetHealth() == 0) { break; } Thread.Sleep(300); } Console.ReadLine(); }
// Selects and returns 2 Celebrity class instances private static (Celebrity, Celebrity) ShowAll() { // These variables are to keep track of the user input state var count1 = 0; var count2 = 0; var showRecords = ""; // make an array of instances var myCelebs = new Celebrity[4]; myCelebs[0] = new Celebrity(0, "Britney Spears", 1.63, 57, 45, 25, false); myCelebs[1] = new ProFighter(1, "Chuck Norris", 1.83, 77.1, 70, 60, true); myCelebs[2] = new Celebrity(2, "Barak Obama", 1.85, 81.6, 56, 35, false); myCelebs[3] = new Celebrity(3, "Donald Trump", 1.90, 107, 63, 12, false); // User input // Missing validation methods while (count1 == 0 && count2 == 0 && showRecords == "") { Console.WriteLine("Select your first fighter by number or enter 'r' for records of previous fights."); // Display fighters foreach (var celeb in myCelebs) { Console.WriteLine(celeb.Name + " with a " + celeb.BladeName + " Press: " + celeb.Id); } var celebString = Console.ReadLine(); // If the user does not want to view previous fight records if (celebString != "r" && count1 == 0 && count2 == 0) { var celebNum = Convert.ToInt32(celebString); // Assign first choice var c1 = myCelebs[celebNum]; // change state for the next choice count1 = 1; c1.ShowStats(); if (count1 == 1 && count2 == 0) { Console.WriteLine("Select your second fighter!"); celebString = Console.ReadLine(); var celebNum1 = Convert.ToInt32(celebString); var c2 = myCelebs[celebNum1]; c2.ShowStats(); showRecords = ""; count2 = 1; return(c1, c2); } } var myReader = new StreamReader("fightrecords.txt"); // Read from file if (celebString == "r") { var consoleLine = " "; while (consoleLine != null) { consoleLine = myReader.ReadLine(); if (consoleLine != null) { Console.WriteLine(consoleLine); } if (consoleLine == null) { Console.WriteLine("Press enter to return to selection!"); showRecords = ""; } } Console.ReadLine(); } myReader.Close(); } return(null, null); }