Published using Google Docs
old - Methods 5 - Olympics/Casino
Updated automatically every 5 minutes

Olympic Champions

OR

Expanded Casino

OPTION 1: Olympic Champions

Create a new file called Assign5_Olympics.java.  

You are writing a program to track the participants in a Decathalon.  Decatheletes compete in multiple events and get points for each event.  Their total points determine the overall champion.

Create 4 variables:

Begin by scanning in the names of TWO competitors.  You will pass these 2 names into every method you write for this assignment.  

Hundred Meter Race

New help code:  public static String hundredMeter(String name1, String name2)

Write a String method called hundredMeter() that:

Back in your main/run function, give 10 points to whoever won the race.  Give 5 points each if it is a tie. It will look something like this:

String winner =  hundredMeter(person1Name, person2Name);

if( winner.equals(person1Name)  ){

                person1points += 10;

        } else if ()  

Print the current standings (the names and points of the two competitors).

Long Jump

New help code:  public static int longJump(String name){ }

Write an int method called longJump() that:

Back in your main/run function, call this function twice (once for each competitor).  Update each person’s total points by adding what Long Jump function calls return

New help code:          

    person1points +=  longJump1(person1name);

    person2points +=  longJump2(person2name);

Print the current standings (the names and points of the two competitors).

Award Medals (final 20%)

Write a VOID method that takes in all 4 variables as parameters (the two names and the two points). It then simply prints who won the Gold Medal and who won the Silver medal.

Back in your main/run function, call the function. Then sit back and cheer for the Canadians!


OPTION 2: Expand on our Casino Example

Several days ago, we introduced parameters with a Casino example that included an isFlush and an isPair method.  Your goal is to complete this example so it determines who wins the hand.  The final result should say: “The Casino Wins!” or “The Player Wins!”.

As part of this assignment, you will need to create a getHighest method.  You may find other methods useful as well. Feel free to create others.

Save the original file as Assign5_Casino.  

Here are the rules for determining the winner.  This is NOT necessarily the order in which you should code your if statements:

Final 20% - What if both have a flush or a pair?  Well if both have a pair, the highest pair should win.  If both have  flush then the highest card should win.  

Ask your teacher for the Casino start code if you do not have it.