OK so my code works for the task at hand. the assignment is to flip a Coin object that is instantiated from a separate Coin class (not shown here). I have written the code correctly so as to calculate the maximum streak of consecutive flips resulting in Heads as the output. I was wondering how I could possibly highlight this streak so when I look the output in the console the streak is visible as it is hard to notice the streak in the list of 100 flips.
here is my code:
public class Runs
{
public static void main (String[] args)
{
final int FLIPS = 100; // number of coin flips
int currentRun =0; // length of the current run of HEADS
int maxRun =0; // length of the maximum run so far
// Create a coin objecti
Coin coin = new Coin();
// Flip the coin FLIPS times
for (int i = 0; i < FLIPS; i++)
{
// Flip the coin & print the result
coin.flip();
int flipCount = i + 1;
System.out.println("Flip " + flipCount +":"+ " " + coin.toString());
// Update the run information
if (coin.isHeads()==true)
{
if (maxRun<currentRun)
{
maxRun=currentRun;
}
currentRun+=1;
}
else
{
currentRun = 0;
}
}
// Print the results
System.out.println("Maximum run of heads in a row! : " + maxRun);
}
}