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

-First, you choose your First Move (you can choose if you start with Black or Wh

ID: 3835275 • Letter: #

Question

-First, you choose your First Move (you can choose if you start with Black or White)_For choosing, you need to select your "First Move"(it is right there on the right side panel)

-Let's say, you choose white! then, you can flip/click on any disks(there is no limit of how many times you flip a disk) and turn it to white.

-When clicking on each disk to turn it to "white", the game(the right panel) should keep track of how many times you clicked on the disks. For example, let's say you fliped/clicked-on 12 disks/Buttons, so at the top, under "White:" it should say 12. But make sure initially you have 2 for each color(black and white) because we start with 2 Black and 2 White.

-To change the color(or to change turn) you just need to click on "Done Moving" Button! For example, you start with white and you flip disks, then you click on "Done Moving" button to start fliping Black disks. remeber that you still need to keep tract of how many Balck disks you turned!

-Also, the game should start over if the button "New Game" is clicked!

******(Please use the provided templates) (Also, you don't need to make the round circle, because that is provided in the template)

(This is just a simple game, and does not work like the actual Reversi game)

The templates: (put codes in these...)(there are 4 different templates)(1 is already done!)

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.Border;

public class ControlPanel extends JPanel {

   //ToDO
}

//---------------------------------------------------------------------------------

import java.awt.BorderLayout;

import javax.swing.JFrame;

public class Reversi extends JFrame {

   // TODO

}

//---------------------------------------------------------------------------------

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;

public class ReversiBoard extends JPanel{
  
   //TODO
}

//---------------------------------------------------------------------------------

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JButton;

public class RoundedButton extends JButton {
   private Color currentColor = Color.lightGray;
  
   public RoundedButton() {
       super();
       setContentAreaFilled(false);
   }
   public boolean isWhite()
   {
       return currentColor.equals(Color.white);
   }
   public boolean isGray()
   {
       return currentColor.equals(Color.lightGray);
   }
   public boolean isBlack()
   {
       return currentColor.equals(Color.darkGray);
   }
   public void paint(Graphics g) {
      
       Graphics2D g2d = (Graphics2D)g;
      
       // Enable antialiasing for shapes
       g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
               RenderingHints.VALUE_ANTIALIAS_ON);
      
       // Draw a border
       g2d.setBackground(Color.black);
       g2d.setColor(Color.black);
       g2d.fillOval(4,4,getWidth()-8,getHeight()-8);
      
       // draw the current color
       g2d.setBackground(currentColor);
       g2d.setColor(currentColor);
       g2d.fillOval(4,4,getWidth()-10,
               getHeight()-10);
   }
   public void setWhite()
   {
       currentColor = Color.white;
   }
   public void setGray()
   {
       currentColor = Color.lightGray;
   }
   public void setBlack()
   {
       currentColor = Color.darkGray;
   }
}

[RoundedButton class is at the top_ it is given to you]

Revers Turn: White White Black: Done Moving First Move: White Black New Game

Explanation / Answer

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.Border;

public class ControlPanel extends JPanel {

   //ToDO
}

//---------------------------------------------------------------------------------

import java.awt.BorderLayout;

import javax.swing.JFrame;

public class Reversi extends JFrame {

   // TODO

}

//---------------------------------------------------------------------------------

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;

public class ReversiBoard extends JPanel{
  
   //TODO
}

//---------------------------------------------------------------------------------

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JButton;

public class RoundedButton extends JButton {
   private Color currentColor = Color.lightGray;
  
   public RoundedButton() {
       super();
       setContentAreaFilled(false);
   }
   public boolean isWhite()
   {
       return currentColor.equals(Color.white);
   }
   public boolean isGray()
   {
       return currentColor.equals(Color.lightGray);
   }
   public boolean isBlack()
   {
       return currentColor.equals(Color.darkGray);
   }
   public void paint(Graphics g) {
      
       Graphics2D g2d = (Graphics2D)g;
      
       // Enable antialiasing for shapes
       g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
               RenderingHints.VALUE_ANTIALIAS_ON);
      
       // Draw a border
       g2d.setBackground(Color.black);
       g2d.setColor(Color.black);
       g2d.fillOval(4,4,getWidth()-8,getHeight()-8);
      
       // draw the current color
       g2d.setBackground(currentColor);
       g2d.setColor(currentColor);
       g2d.fillOval(4,4,getWidth()-10,
               getHeight()-10);
   }
   public void setWhite()
   {
       currentColor = Color.white;
   }
   public void setGray()
   {
       currentColor = Color.lightGray;
   }
   public void setBlack()
   {
       currentColor = Color.darkGray;
   }
}