Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 2 — Shooting Game This is a really difficult question, in part because

ID: 3764163 • Letter: Q

Question


Question 2 — Shooting Game
This is a really difficult question, in part because it’s so big.
There are a lot of functions in this one, perhaps too many, but
it’s great practice! This assignment is designed to be
overwhelming. The point of functions is to help you take a
really hard problem and break it down. If you find this
overwhelming, that’s the point. Jump in and start
implementing those functions.
You will have a player ship (a circle) at the bottom of the
screen, and an enemy ship at the top of the screen, as shown
on the right. They can move left and right only. They shoot at
each other. The player can shoot by pressing a mouse button,
but if they shoot while a bullet is still on the screen, nothing
happens. The enemy is constantly shooting at the player (with
a maximum of one bullet on the screen at a time), and moving around randomly.
If the player hits the enemy, the enemy shrinks to make it harder to hit. If the enemy is killed, a new
enemy ship appears at a random horizontal location to take its place. If the enemy hits the player,
the game is over. (There’s no way to win this game – the objective is to stay alive as long as you
can. You could add a counter for the number of ships killed, and print that to the console as a score,
but this is not required.)
You have been provided with a template file for this question that gives you some of the necessary
final constants, and the setup and draw blocks. Look at the draw block, and notice how clean it is! It
only has 3 commands, because the entire program is broken down into functions, as described
below. In addition to the global constants, you will also need suitable global variables, such as the
player’s position (x only – y is fixed), if they are alive (a boolean variable), the player bullet’s
position (x and y), and whether the bullet is currently moving. You will need similar variables for
the enemy, and also the enemy’s size, since it changes.
There are two kinds of functions in this program. A large number of the functions take no
parameters, return nothing, and work exclusively with global variables and constants. They
implement the basic game logic. In addition, there are re-usable utility functions that will be useful
in multiple places. As in Question 1, you must write the functions exactly as specified below.
Game Logic Functions
Here are the game logic functions you will need to make. Most of them are very small. They are
listed in alphabetical order, in the same order they should appear in your file. It is advisable to
implement them one small step at a time. Read the hint at the end of the question before you begin.
void doEnemy() – This function should use newEnemy to create an enemy, if there isn’t one.
Otherwise, it should be very similar to doPlayer. It should use moveEnemy and drawShip to
make the enemy ship move on the screen. (The ship should still be drawn if the player is dead and
the game is over, but it should not move anymore.) If the game isn’t over, it should use
moveEnemyBullet and drawBullet to make the enemy’s bullet move (if there is one), and ireEnemyBullet to create a new bullet (if there isn’t already an enemy bullet on the screen).
(There should be no more bullets after the game is over.) See the descriptions of those functions for
more details.
void doPlayer() – This function should control the player’s ship (for one frame). It should use
movePlayer and drawShip to make the player’s ship move on the screen. (The ship should still
be drawn if the player is dead and the game is over, but it should not move anymore.) It should use
movePlayerBullet and drawBullet to make the player’s bullet move (if there is one), and
firePlayerBullet to create a new bullet (if the mouse is pressed, and there isn’t already a bullet
on the screen). See the descriptions of those functions for more details.
void firePlayerBullet() and void fireEnemyBullet() – These functions should create
new bullets at the location of the corresponding ship.
void gameOver() – This function should display the “game over” text GAME_OVER_MSG at the
center of the screen. Note that the screen is not cleared, so the player can see the end condition.
void movePlayer() and void moveEnemy() – These functions should change the X location
of the corresponding ship. These functions should first calculate where the ship wants to go – the
player’s ship should want to go to the current mouseX position, and the enemy’s ship should want
to go to a random X location anywhere within the screen (that would be really hard to hit!). But the
ships aren’t allowed to move very far each frame. Use moveHorizontal to calculate the actual
new X coordinate that will be allowed (see that function’s description for details), and use that to
move the ship.
void movePlayerBullet() and void moveEnemyBullet() – These functions should adjust
the Y position of the appropriate bullet. The player’s bullet moves by BULLET_SPEED pixels each
frame, but the enemy’s bullet moves by 2*BULLET_SPEED pixels each frame. (The enemy cheats!)
If the bullet moves beyond the top or bottom of the screen, the proper global variables should be
changed to indicate this fact. Use bulletHitCircle (below) to detect when a bullet hits the
opposing ship. Set the proper global variables when this happens.
void newEnemy() – This function should create a new, smaller, enemy ship, to replace one that
was just destroyed, or possibly the first one of the game. It should multiply the size of the enemy
ship by ENEMY_SHRINK_RATE, create a new ship at a random X location (making sure that the
whole enemy is visible), and set the appropriate global variables to indicate that there is now an
enemy ship.
Utility Functions
Here are the more generic helper utility functions that you will have to make. The descriptions
above refer to these functions.
boolean bulletHitCircle(float bulletX, float bulletY,
float circleX, float circleY, float circleR) –
This function should return true if the given (x,y) location of the bullet is inside the circle (ship)
with the given centre and radius. Use the distance of the bullet from the circle’s centre to determine
this.
void drawBullet(float x, float y, boolean up) – This function should draw a bullet
consisting of a vertical line with one end at the point (x,y). It should have a random greyscale color.
The line should have a “tail” behind it that goes BULLET_TAILgiven point. The parameter up indicates which way the bullet is moving. (If it’s moving up, the tail
should be below (x,y).)
void drawShip(float x, float y, float r, int shipColor, boolean up) – This
function should draw a circle with radius r and centre (x,y), using the indicated shipColor. There
should also be a vertical line from the centre of the circle to an edge, as shown in the picture at the
beginning of this question. The parameter up should control whether the line is drawn up or down
from the centre.
float moveHorizontal(float position, float r, float move) – This function
should accept the current X location of a ship (position) with a given radius (r), and the
preferred new X location (move). It should limit the amount of movement according to these rules:
The ship cannot move more than MAX_MOVE pixels from its current position (in either
direction).
No part of the ship can go off the edge of the screen, even a little. You need to use the radius
for this.
Return the X value to use to move the ship in the desired direction, but no more than is allowed
by these rules. (Don’t actually move a ship – that’s the job of movePlayer and moveEnemy.)
Hints: Get the framework set up first. Type up all the function headers and give them fake return
data. Then focus on one function at a time and implement it. Choose a sensible order so that you
can test and debug the program one function (or a few functions) at a time. Perhaps draw the
player’s ship. Then make it move. Then add player bullets. And so on. Most likely
bulletHitCircle should be the last thing to add. Sometimes you can write small amounts of
“throw-away” code to help with this by calling and testing your newly-implemented functions. If
you don’t understand exactly what a function is supposed to do, consider how is used in the rest of
your program, or ask for help.


randoTIL

Explanation / Answer

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.util.Random;
import java.util.ArrayList;




public class CircleCannonShooter extends JFrame
{
  
  

  
private JPanel mainPanel;
private JPanel topPanel;
private GamePanel gamePanel;
private JPanel bottomPanel;
  
  
private JMenuBar toolBarMenu;
private JMenu gameMenu;
private JMenu infoMenu;

private JMenuItem newGameButton;
private JMenuItem pauseButton;
private JSeparator separatorBar;
private JMenuItem quitButton;

  
private JMenuItem helpButton;
private JMenuItem aboutButton;
  

private JPanel statusContainer;
  
private JLabel statusLabel;
private JLabel timeRemainingLabel;
  
  
private JLabel scoreLabel;
  
private Font labelFont = new Font("Consolas", Font.PLAIN, 12);
private Font menuFont = new Font("Times New Roman", Font.PLAIN, 12);
private Font gameOverFont = new Font("Consolas", Font.PLAIN, 12);

private Timer timer;
private final byte timerDelay = 10;
  
private DecimalFormat timeFormatter = new DecimalFormat("00");
  
private byte timeRemainingSeconds;
private byte timeRemainingMilliseconds;
private final byte maxMilliseconds = 99;
private final byte minMilliseconds = 0;
  
private final byte maxSeconds = 60;
  

private int score;
private int highScore = 5000;
  
private int numberOfBalloonsHit;
private int numberOfShotsMade;
  

private Timer startTimer;
private final int startTimerDelay = 1;
private final int initialMilliSecondsToStart = 5000;
private int milliSecondsToStart;
  
  
private Timer endTimer;
private final byte endTimerDelay = 100;
private int secondsSinceStartOfEndTimer = 0;

private Color colorOfCannon = Color.BLACK;
private Color colorOfPlayerCannonball = Color.BLACK;
private Color colorOfBalloon = Color.RED;
  
private Graphics cannonGraphicsDevice;
private Graphics cannonBallGraphicsDevice;
private Graphics balloonGraphicsDevice;
private Graphics debrisGraphicsDevice;
  

  
private final byte cannonLength = 100;
  
private int endX;
private int endY;
  
private double initialAngle = 0.0;
private final double maxPositiveInitialAngle = (5 * Math.PI) / 12;
  
private final double maxNegativeInitialAngle = (-5 * Math.PI) / 12;

private double angleDuringShoot;
  
private static ArrayList<Double> listOfAnglesForCannon;
private static ArrayList<Integer> listOfXValuesForEdgeOfCannon;
private static ArrayList<Integer> listOfYValuesForEdgeOfCannon;
  
  

private int balloonX;
private int balloonY;
private int balloonWidth;
private int balloonHeight;
  
private Random balloonGenerator;
  
private int balloonDebrisX;
private int balloonDebrisY;
  
  
private Timer cannonBallTimer;
private Timer balloonHitTimer;
private int cannonBallX;
private int cannonBallY;
private final int cannonBallWidth = 10;
private final int cannonBallHeight = 10;
private int timeSinceBalloonHit = 0;
  
private String[] hitMessages = {"BOOM!", "BINGO!", "Bullseye!", "Keep up the pace!", "That's one balloon down!", "Hit!", "A balloon has been popped!", "One stricken balloon!", "Balloon popped!",
"Show off your shooting!"
};
private Random messageSelector;
private int messageIndex;
  
private final byte defaultMaxNumberOfShots = 1;
private byte numberOfShots = 0;
  
  
private boolean gameOnMode = false;
private boolean gameOnPause = false;
private boolean gameNotRunning = true;
private boolean balloonIsPainted = false;

private String currentStatus = "";
  
  
public CircleCannonShooter()
{


mainPanel = new JPanel();
mainPanel.setLayout(new BorderLayout());

topPanel = new JPanel();
gamePanel = new GamePanel();
bottomPanel = new JPanel();



topPanel.setLayout(new BorderLayout());
topPanel.setBackground(Color.LIGHT_GRAY);

statusContainer = new JPanel();
statusContainer.setLayout(new BorderLayout());
statusContainer.setBackground(Color.LIGHT_GRAY);

statusLabel = new JLabel(" ");
statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
statusLabel.setFont(labelFont);
statusLabel.setBackground(Color.GRAY);

timeRemainingLabel = new JLabel("Limit : " + timeRemainingSeconds + "." + timeFormatter.format(timeRemainingMilliseconds));
timeRemainingLabel.setHorizontalAlignment(SwingConstants.CENTER);
timeRemainingLabel.setFont(labelFont);

statusContainer.add(statusLabel);
topPanel.add(statusContainer, BorderLayout.NORTH);
topPanel.add(timeRemainingLabel);


gamePanel.addKeyListener(new KeyboardListener());
gamePanel.setBorder(new javax.swing.border.LineBorder(Color.BLUE));

  
scoreLabel = new JLabel("Score: " + score + " Balloons Hit: " + numberOfBalloonsHit);
scoreLabel.setFont(labelFont);
bottomPanel.add(scoreLabel);


mainPanel.add(topPanel, BorderLayout.NORTH);
mainPanel.add(gamePanel);
mainPanel.add(bottomPanel, BorderLayout.SOUTH);


toolBarMenu = new JMenuBar();
gameMenu = new JMenu("Game");
infoMenu = new JMenu("Info");


newGameButton = new JMenuItem("New Game");
pauseButton = new JMenuItem("Pause");
separatorBar = new JSeparator();
quitButton = new JMenuItem("Quit");

newGameButton.addActionListener(new MenuBarListener());
pauseButton.addActionListener(new MenuBarListener());
quitButton.addActionListener(new MenuBarListener());

newGameButton.setFont(menuFont);
pauseButton.setFont(menuFont);
quitButton.setFont(menuFont);

newGameButton.setForeground(Color.RED);
pauseButton.setForeground(Color.RED);
separatorBar.setForeground(Color.BLUE);
quitButton.setForeground(Color.RED);

gameMenu.add(newGameButton);
gameMenu.add(pauseButton);
gameMenu.add(separatorBar);
gameMenu.add(quitButton);

  

helpButton = new JMenuItem("Help");
aboutButton = new JMenuItem("About");

helpButton.addActionListener(new MenuBarListener());
aboutButton.addActionListener(new MenuBarListener());

helpButton.setFont(menuFont);
aboutButton.setFont(menuFont);

helpButton.setForeground(Color.RED);
aboutButton.setForeground(Color.RED);

infoMenu.add(helpButton);
infoMenu.add(aboutButton);

toolBarMenu.add(gameMenu);
toolBarMenu.add(infoMenu);

toolBarMenu.setBackground(Color.BLACK);

add(mainPanel);

gamePanel.setFocusable(true);
gamePanel.requestFocusInWindow();
  

timer = new Timer(timerDelay, new TimerListener());
startTimer = new Timer(startTimerDelay, new TimerListener());
endTimer = new Timer(endTimerDelay, new TimerListener());
cannonBallTimer = new Timer(20, new TimerListener());
balloonHitTimer = new Timer(10, new TimerListener());

balloonGenerator = new Random();
messageSelector = new Random();

gamePanel.createListOfAngles();
gamePanel.createCannonBoundariesOfX();
gamePanel.createCannonBoundariesOfY();

  

setJMenuBar(toolBarMenu);
setTitle("Circle Cannon Shooter");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setSize(800, 600);
setResizable(false);
setVisible(true);
}
  
  
public static void main(String[] args)
{


T
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch(Exception e)
{
  
}

new CircleCannonShooter();

}
  

private class GamePanel extends JPanel
{

private static final long serialVersionUID = 310112728276495178L;

public GamePanel()
{
setBackground(Color.WHITE);
}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(Color.WHITE);
  
if (cannonGraphicsDevice == null && cannonBallGraphicsDevice == null && balloonGraphicsDevice == null)
{
cannonGraphicsDevice = g.create();
cannonBallGraphicsDevice = g.create();
balloonGraphicsDevice = g.create();
debrisGraphicsDevice = g.create();
  
cannonGraphicsDevice.setColor(colorOfCannon);
cannonBallGraphicsDevice.setColor(colorOfPlayerCannonball);
balloonGraphicsDevice.setColor(colorOfBalloon);
debrisGraphicsDevice.setColor(colorOfCannon);
}
  
if (startTimer.isRunning() || timer.isRunning() || endTimer.isRunning())
{
endX = calculateEndX();
endY = calculateEndY();
  
cannonGraphicsDevice.drawLine(400, 447, endX, endY);
}
if (timer.isRunning())
{
if (!balloonIsPainted)
{
do
{
balloonX = balloonGenerateX();
balloonY = balloonGenerateY();
  
do
{
balloonWidth = balloonGenerateWidthAndHeight();
}
while (balloonWidth < 30);
  
balloonHeight = balloonWidth;
}   
while(isBalloonInAreaOfCannon(balloonX, balloonY));
balloonIsPainted = true;
}
  
if(numberOfShots == 1)
{
cannonBallGraphicsDevice.fillOval(cannonBallX, cannonBallY, cannonBallWidth, cannonBallHeight);

if(cannonBallHitsBalloon())
{   
balloonIsPainted = false;
  
balloonDebrisX = balloonX;
balloonDebrisY = balloonY;
  
timeSinceBalloonHit = 0;
balloonHitTimer.start();
  
balloonGraphicsDevice.clearRect(balloonX, balloonY, balloonWidth, balloonHeight);
  
score += 500;
numberOfBalloonsHit++;
  
numberOfShots--;
cannonBallTimer.stop();
  
  
}
}
  
if (timeSinceBalloonHit < 200)
{

if (balloonDebrisX < 400 && balloonDebrisY > 100)
{
debrisGraphicsDevice.drawOval(balloonDebrisX, balloonDebrisY - 10, 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX + 10, balloonDebrisY, 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX, balloonDebrisY + 10, 10, 10);
}
else if (balloonDebrisX < 400 && balloonDebrisY > 50)
{
debrisGraphicsDevice.drawOval(balloonDebrisX + 10, (balloonDebrisY + 10), 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX + 10, balloonDebrisY, 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX, (balloonDebrisY + 10), 10, 10);
}
else if (balloonDebrisX > 400 && balloonDebrisY > 100)
{
debrisGraphicsDevice.drawOval(balloonDebrisX, balloonDebrisY - 10, 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX - 10, balloonDebrisY, 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX, balloonDebrisY + 10, 10, 10);
}
else if (balloonDebrisX > 400 && balloonDebrisY > 50)
{
debrisGraphicsDevice.drawOval(balloonDebrisX - 10, (balloonDebrisY - 10), 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX - 10, balloonDebrisY, 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX, (balloonDebrisY - 10), 10, 10);
}
else if (balloonDebrisX == 400 && balloonDebrisY > 50)
{
debrisGraphicsDevice.drawOval(balloonDebrisX, (balloonDebrisY + 10), 10, 10);
debrisGraphicsDevice.drawOval(balloonDebrisX, (balloonDebrisY - 10), 10, 10);
}
else
debrisGraphicsDevice.drawOval(balloonDebrisX, (balloonDebrisY + 10), 10, 10);

repaint();
}
else
{
debrisGraphicsDevice.clearRect(balloonDebrisX, balloonDebrisY, 10, 10);
repaint();
}
balloonGraphicsDevice.fillOval(balloonX, balloonY, balloonWidth, balloonHeight);
}
  
scoreLabel.setText("Score: " + score + " Balloons Hit: " + numberOfBalloonsHit);
}

private void initializeGame()
{
gamePanel.setFocusable(true);
  
milliSecondsToStart = initialMilliSecondsToStart;
  
numberOfBalloonsHit = 0;
numberOfShotsMade = 0;
numberOfShots = 0;
  
timeRemainingSeconds = maxSeconds;
timeRemainingMilliseconds = minMilliseconds;
initialAngle = 0.0;
startTimer.start();
}

private void fire()
{
if (numberOfShots != defaultMaxNumberOfShots)
{
numberOfShots++;
numberOfShotsMade++;
  
angleDuringShoot = initialAngle;
  
cannonBallX = endX - (cannonBallWidth / 2);
cannonBallY = endY - (cannonBallWidth / 2);
  
cannonBallTimer.start();
}
}

private boolean cannonBallHitsBalloon()
{
return (((cannonBallX > balloonX && cannonBallX < balloonX + balloonWidth) || (cannonBallX + cannonBallWidth > balloonX && cannonBallX + cannonBallWidth < balloonX + balloonWidth))
&&
((cannonBallY > balloonY && cannonBallY < balloonY + balloonWidth) || (cannonBallY + cannonBallWidth > balloonY && cannonBallY + cannonBallWidth < balloonY + balloonWidth)));
}

private int calculateEndX()
{
return (int)(400 - (Math.sin(initialAngle) * cannonLength));
}

private int calculateEndY()
{
return (int)(447 - Math.cos(initialAngle) * cannonLength);
}

private int balloonGenerateX()
{
return balloonGenerator.nextInt(600);
}

private int balloonGenerateY()
{
return balloonGenerator.nextInt(347);
}

private int balloonGenerateWidthAndHeight()
{
return balloonGenerator.nextInt(50);
}


private boolean isBalloonInAreaOfCannon(int balloonX, int balloonY)
{
boolean balloonIsInCannon = false;
  
for (double x = maxPositiveInitialAngle; x <= maxNegativeInitialAngle; x -= (Math.PI / 90))
{
if (x > 0.0)
{
if(((balloonX + balloonWidth)>=listOfXValuesForEdgeOfCannon.get(listOfAnglesForCannon.indexOf(x))
&&
(balloonY + balloonWidth) > listOfYValuesForEdgeOfCannon.get(listOfAnglesForCannon.indexOf(x))))
balloonIsInCannon = true;
}
else
{
if (((balloonX) <= listOfXValuesForEdgeOfCannon.get(listOfAnglesForCannon.indexOf(x))
&&
(balloonY + balloonWidth) > listOfYValuesForEdgeOfCannon.get(listOfAnglesForCannon.indexOf(x))))
balloonIsInCannon = true;
}
}
  
return balloonIsInCannon;
}

private void createListOfAngles()
{
listOfAnglesForCannon = new ArrayList<Double>();
for (double x = maxPositiveInitialAngle; x >= maxNegativeInitialAngle; x -= (Math.PI / 90))
{
listOfAnglesForCannon.add(x);
}
  
}

private void createCannonBoundariesOfX()
{
listOfXValuesForEdgeOfCannon = new ArrayList<Integer>();
for (double x = maxPositiveInitialAngle; x >= maxNegativeInitialAngle; x -= (Math.PI / 90))
{
listOfXValuesForEdgeOfCannon.add((int)(400 - (Math.sin(x) * cannonLength)));
}
  
}

private void createCannonBoundariesOfY()
{
listOfYValuesForEdgeOfCannon = new ArrayList<Integer>();
for (double x = maxPositiveInitialAngle; x >= maxNegativeInitialAngle; x -= (Math.PI / 36))
{
listOfYValuesForEdgeOfCannon.add((int)(447 - Math.cos(initialAngle) * cannonLength));
}
}
}
  

  
private class TimerListener implements ActionListener
{
public void actionPerformed(ActionEvent f)
{
gamePanel.setFocusable(true);
  

if (f.getSource() == startTimer)
{
  
  
if (milliSecondsToStart == 5000)
{
helpButton.setEnabled(false);
aboutButton.setEnabled(false);
}
else if (milliSecondsToStart > 3000)
{
gamePanel.repaint();
timeRemainingLabel.setText("Limit : " + timeRemainingSeconds + "." + timeFormatter.format(timeRemainingMilliseconds));

statusContainer.setBackground(Color.BLACK);
statusLabel.setForeground(Color.WHITE);

currentStatus = "GET READY";
}

else
{
startTimer.stop();
statusLabel.setFont(labelFont);
statusContainer.setBackground(Color.LIGHT_GRAY);

currentStatus = " ";
}
  
  
milliSecondsToStart -= 10;
}

else if (f.getSource() == timer)
{
  
  
if (timeRemainingSeconds == maxSeconds && timeRemainingMilliseconds == minMilliseconds && timer.isRunning())
{   
gameOnMode = true;

helpButton.setEnabled(true);
aboutButton.setEnabled(true);

gamePanel.repaint();
}
  
if (timeRemainingSeconds == 0 && timeRemainingMilliseconds == 0)
{
gamePanel.setFocusable(true);
gameOnMode = false;
timeRemainingLabel.setText("Limit : " + timeRemainingSeconds + "." + timeFormatter.format(timeRemainingMilliseconds));
timer.stop();
endTimer.start();

statusLabel.setForeground(Color.RED);
statusContainer.setBackground(Color.BLACK);

currentStatus = "Your time is up!";
}
else if (timeRemainingMilliseconds == minMilliseconds)
{
timeRemainingSeconds--;
timeRemainingMilliseconds = maxMilliseconds;
timeRemainingLabel.setText("Limit : " + timeRemainingSeconds + "." + timeFormatter.format(timeRemainingMilliseconds));
}
else if (timeRemainingSeconds < 5)
{
if (timeRemainingSeconds > 3)
currentStatus = "You're running out of time!";

if ((timeRemainingSeconds >= 0 && (timeRemainingMilliseconds % 2) == 0))
{
  
timeRemainingLabel.setForeground(Color.RED);
timeRemainingLabel.setText("Limit : " + timeRemainingSeconds + "." + timeFormatter.format(timeRemainingMilliseconds));
timeRemainingMilliseconds--;
}
else
{
timeRemainingLabel.setForeground(Color.BLACK);
timeRemainingLabel.setText("Limit : " + timeRemainingSeconds + "." + timeFormatter.format(timeRemainingMilliseconds));
timeRemainingMilliseconds--;
}
  
}
else
{
timeRemainingMilliseconds--;
timeRemainingLabel.setText("Limit : " + timeRemainingSeconds + "." + timeFormatter.format(timeRemainingMilliseconds));

}
  
}




  


  

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote