%% saintsfinaldrive.m % created by Adam Wisbrock clear; clc; scored_touchdown = false; lost_ball = false; yards = 75; first_down = 10; attempts = 4; disp('Welcome to Saints Super Bowl Final Drive!'); disp('Time to take over the Saints offense. The score is 31-27 Colts, and'); disp('the ball is on your own 25-yd. line.'); while (scored_touchdown == false && lost_ball == false && attempts > 0) disp(['There are ' num2str(first_down) ' yards before a first down, and']); disp(['you have ' num2str(attempts) ' attempts.']); disp('You can:'); disp('1. Hand it off to Pierre Thomas'); disp('2. Screen pass to Reggie Bush'); disp('3. Play action pass to Marques Colston'); disp('4. Deep pass to Robert Meachem'); play_call = input(['You have ' num2str(yards) ' yards to go. What will you do? ']); switch play_call case 1 disp('You hand it off to Pierre Thomas!'); thomas = randi(10,1) - 4; fumble = randi(60,1); if fumble == 1 disp('You fumble the ball!'); disp(''); disp('The Colts kneel out the clock and win Super Bowl XLIV!'); disp('Better luck next time.'); lost_ball = true; else disp(['Pierre Thomas runs the ball up the middle for a net gain of ' num2str(thomas) ' yards!']); yards = yards - thomas; first_down = first_down - thomas; attempts = attempts - 1; if (yards == 0 || yards < 0) disp('TOUCHDOWN! THE SAINTS WIN!'); scored_touchdown = true; end if (first_down == 0 || first_down <0) disp('That''s a first down!'); attempts = 4; first_down = 10; end end case 2 bush = randi(9,1); bush_catch = randi(10,1); disp('You throw a screen pass to Reggie Bush!'); if bush_catch < 7 disp('That''s an incomplete pass!'); attempts = attempts - 1; else disp(['He catches the ball for a gain of ' num2str(bush) ' yards!']); yards = yards-bush; first_down = first_down - bush; attempts = attempts - 1; if yards == 0 || yards < 0 disp('TOUCHDOWN! THE SAINTS WIN!'); scored_touchdown = true; end if (first_down == 0 || first_down <0) disp('That''s a first down!'); attempts = 4; first_down = 10; end end case 3 disp('You throw a play action pass to Marques Colston!'); colston = randi(15,1)+5; colston_catch = randi(10,1); if colston_catch < 8 disp('It''s incomplete!'); attempts = attempts - 1; else disp(['He catches the ball for a gain of ' num2str(colston) ' yards!']); yards = yards-colston; first_down = first_down - colston; attempts = attempts - 1; if yards == 0 || yards < 0 disp('TOUCHDOWN! THE SAINTS WIN!'); scored_touchdown = true; end if (first_down == 0 || first_down <0) disp('That''s a first down!'); attempts = 4; first_down = 10; end end case 4 disp('You throw it deep to Robert Meachem!'); meachem = randi(40,1)+20; meachem_catch = randi(10,1); if meachem_catch < 10 disp('It''s incomplete!'); attempts = attempts - 1; else disp(['He catches the ball for a gain of ' num2str(meachem) ' yards!']); yards = yards-meachem; first_down = first_down - meachem; attempts = attempts - 1; if yards == 0 || yards < 0 disp('TOUCHDOWN! THE SAINTS WIN!'); scored_touchdown = true; end if (first_down == 0 || first_down <0) disp('That''s a first down!'); attempts = 4; first_down = 10; end end end end if (attempts == 0) disp('The Saints turn the ball over!'); disp('The Colts kneel out the clock and win Super Bowl XLIV!'); disp('Better luck next time.'); lost_ball = true; end