Question

JAVA JAR HELP...ASAP I have the code that i need for my game Connect 4, but...

JAVA JAR HELP...ASAP

I have the code that i need for my game Connect 4, but i need to create a jar file . the instructions are below. It has to pass some parameters. I am really confused on doing so.l I dont know what to do next. Can someone help me and give detailed descritiopm opn how you ran the jar file in CMD

JAVA JAR HELP...ASAP I have the code that i need f

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Connect4 {

  
  
  
  
  
  
public static void main(String[] args) {
  
int s1 = Integer.parseInt(args[0]);
int s2 = Integer.parseInt(args[1]);

System.out.println("FIRST STRING : " + s1 + " SECOND STRING : " + s2);
Connect4JFrame newF = new Connect4JFrame(s2, s2);
      
newF.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
      
newF.setVisible(true);
   }
}

class Connect4JFrame extends JFrame implements ActionListener {
  

private static final long SV1 = 1L;
private Button buttotn1, buttotn2, buttotn3, buttotn4, buttotn5, buttotn6, buttotn7;
private Label lSpacer;  
MenuItem neww, exitt, blackk, bluee;  
int[][]   theeArrayArray;  
boolean   end=false;  
boolean   startTHEGAME;  
public static final int BLANK = 0;  
public static final int BLACK = 1;  
public static final int BROWN = 2;
public static final int theROW = 6;   // 6 rows  
public static final int theColumn = 6;   // 7 columns
public static final String theSpace = " ";
int activeColour = BLACK;
  
  
  
  
  
  
  
  

public Connect4JFrame(int x, int y) {

setTitle("CS 151 CONNECT 4 HOMEWORK 3");
MenuBar mbar = new MenuBar();
      
Menu fileMenu = new Menu("File");
exitt = new MenuItem("Exit");
exitt.addActionListener(this);
fileMenu.add(exitt);
mbar.add(fileMenu);
Menu optMenu = new Menu("Options");

mbar.add(optMenu);
setMenuBar(mbar);

      
Panel panel = new Panel();

buttotn1 = new Button("one");
buttotn1.addActionListener(this);
panel.add(buttotn1);
lSpacer = new Label(theSpace);
panel.add(lSpacer);


buttotn2 = new Button("two");
buttotn2.addActionListener(this);
panel.add(buttotn2);
lSpacer = new Label(theSpace);
panel.add(lSpacer);


buttotn3 = new Button("three");
buttotn3.addActionListener(this);
panel.add(buttotn3);
lSpacer = new Label(theSpace);
panel.add(lSpacer);


buttotn4 = new Button("four");
buttotn4.addActionListener(this);
panel.add(buttotn4);
lSpacer = new Label(theSpace);
panel.add(lSpacer);


buttotn5 = new Button("five");
buttotn5.addActionListener(this);
panel.add(buttotn5);
lSpacer = new Label(theSpace);
panel.add(lSpacer);


buttotn6 = new Button("six");
buttotn6.addActionListener(this);
panel.add(buttotn6);
lSpacer = new Label(theSpace);
panel.add(lSpacer);

add(panel, BorderLayout.NORTH);
initialize();

// Set to a reasonable size.
setSize(1024, 768);
  
} // Connect4

  
  
  
  
public void paint(Graphics g) {
  
g.setColor(Color.ORANGE);
g.fillRect(110, 50, 100+100*theColumn, 100+100*theROW);

for (int row=0; row<theROW; row++)
for (int col=0; col<theColumn; col++) {

if (theeArrayArray[row][col]==BLANK) g.setColor(Color.RED);
if (theeArrayArray[row][col]==BLACK) g.setColor(Color.BLACK);
if (theeArrayArray[row][col]==BROWN) g.setColor(Color.BLUE);

g.fillOval(160+100*col, 100+100*row, 100, 100);

           }
check4(g);

   } // paint

  
  
  
public void initialize() {
  
  
theeArrayArray = new int [theROW][theColumn] ;
      
for (int row = 0; row<theROW; row++)
for (int col = 0; col<theColumn; col++)
              
theeArrayArray [row] [col] = BLANK;
      
startTHEGAME = false;
      
   } // initialize

  
  
  
  
  
  
  
  

  
  
  
  
  
  
public void PutCircle(int z) {
  
  
   // put a disk on top of column n
       // if game is won, do nothing
      
if (end) return;
startTHEGAME = true;
int row;
z -- ;

for (row=0; row<theROW; row++ )
  
if (theeArrayArray [row] [z ] > 0 ) break;

if (row>0) {
theeArrayArray [ -- row] [z] = activeColour;

if (activeColour == BLACK)
activeColour = BROWN;

   else
activeColour = BLACK;
           repaint();
       }
   }

  
  
  
  
  
  
public void theWinnerIS(Graphics f, int z) {

f.setColor(Color.BLACK);
f.setFont(new Font("Courier", Font.ITALIC, 50));
if ( z == BLACK )
f.drawString("BLACK Is The Winner", 2, 200);
else
f.drawString("BLUE Is The Winner!", 2, 200);
end=true;
   }

  
  
  
  
  
  
  
  
  
public void check4(Graphics g) {
   // see if there are 4 disks in a row: horizontal, vertical or diagonal
       // horizontal rows
for (int row=0; row<theROW; row++) {
for (int col=0; col<theColumn-3; col++) {
  
int curr = theeArrayArray[row][col];

if (curr>0
       && curr == theeArrayArray[row][col+1]
       && curr == theeArrayArray[row][col+2]
       && curr == theeArrayArray[row][col+3]) {
   theWinnerIS(g, theeArrayArray[row][col]);
}
}
}
       // vertical columns
for (int col=0; col<theColumn; col++) {
for (int row=0; row<theROW-3; row++) {
  
int curr = theeArrayArray[row][col];
if (curr>0
           && curr == theeArrayArray[row+1][col]
           && curr == theeArrayArray[row+2][col]
           && curr == theeArrayArray[row+3][col])
   theWinnerIS(g, theeArrayArray[row][col]);
   }
}
       // diagonal lower left to upper right
for (int row=0; row<theROW-3; row++) {
for (int col=0; col<theColumn-3; col++) {
  
int curr = theeArrayArray[row][col];
if (curr>0
           && curr == theeArrayArray[row+1][col+1]
           && curr == theeArrayArray[row+2][col+2]
           && curr == theeArrayArray[row+3][col+3])
   theWinnerIS(g, theeArrayArray[row][col]);
   }
}

       // diagonal upper left to lower right
for (int row=theROW-1; row>=3; row--) {
for (int col=0; col<theColumn-3; col++) {
int curr = theeArrayArray[row][col];
   if (curr>0
               && curr == theeArrayArray[row-1][col+1]
               && curr == theeArrayArray[row-2][col+2]
               && curr == theeArrayArray[row-3][col+3])
       theWinnerIS(g, theeArrayArray[row][col]);
  
}
}
} // end check4

  
  
  
  
  
  
  
public void actionPerformed(ActionEvent z) {
  
if (z.getSource() == buttotn1)
PutCircle(1);
      
else if (z.getSource() == buttotn2)
PutCircle(2);
      
else if (z.getSource() == buttotn3)
PutCircle(3);
      
else if (z.getSource() == buttotn4)
PutCircle(4);
      
else if (z.getSource() == buttotn5)
PutCircle(5);
      
else if (z.getSource() == buttotn6)
PutCircle(6);
  
else if (z.getSource() == neww) {
end=false;
initialize();
repaint();


}

else if (z.getSource() == exitt) {
System.exit(0);
}

else if (z.getSource() == blackk) {
  
           // don't change colour to play in middle of game
if (!startTHEGAME) activeColour=BLACK;

}

else if (z.getSource() == bluee) {
if (!startTHEGAME) activeColour=BROWN;

}
} // end ActionPerformed

} // class

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
JAVA JAR HELP...ASAP I have the code that i need for my game Connect 4, but...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • This is my code for my game called Reversi, I need to you to make the...

    This is my code for my game called Reversi, I need to you to make the Tester program that will run and complete the game. Below is my code, please add comments and Javadoc. Thank you. public class Cell { // Displays 'B' for the black disk player. public static final char BLACK = 'B'; // Displays 'W' for the white disk player. public static final char WHITE = 'W'; // Displays '*' for the possible moves available. public static...

  • Can you please help me to run this Java program? I have no idea why it...

    Can you please help me to run this Java program? I have no idea why it is not running. import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.DecimalFormat; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; @SuppressWarnings({"unchecked", "rawtypes"}) public class SmartPhonePackages extends JFrame { private static final long serialVersionID= 6548829860028144965L; private static final int windowWidth = 400; private static final int windowHeight = 200; private static final double SalesTax = 1.06; private static JPanel panel;...

  • Hi I need help with a java program that I need to create a Airline Reservation...

    Hi I need help with a java program that I need to create a Airline Reservation System I already finish it but it doesnt work can someone please help me I would be delighted it doesnt show the available seats when running the program and I need it to run until someone says no for booking a seat and if they want to cancel a seat it should ask the user to cancel a seat or continue booking also it...

  • In Java Swing, in my ButtonHandler class, I need to have 2 different showDialog messages show...

    In Java Swing, in my ButtonHandler class, I need to have 2 different showDialog messages show when my acceptbutton1 is pressed. One message is if the mouse HAS been dragged. One is if the mouse HAS NOT been dragged. /// I tried to make the Points class or the Mouse Dragged function return a boolean of true, so that I could construct an IF/THEN statement for the showDialog messages, but my boolean value was never accepted by ButtonHandler. *************************ButtonHandler class************************************...

  • Need Help ASAP!! Below is my code and i am getting error in (public interface stack)...

    Need Help ASAP!! Below is my code and i am getting error in (public interface stack) and in StackImplementation class. Please help me fix it. Please provide a solution so i can fix the error. thank you.... package mazeGame; import java.io.*; import java.util.*; public class mazeGame {    static String[][]maze;    public static void main(String[] args)    {    maze=new String[30][30];    maze=fillArray("mazefile.txt");    }    public static String[][]fillArray(String file)    {    maze = new String[30][30];       try{...

  • I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label;...

    I am getting this Error can you please fix my Java code. import java.awt.Dialog; import java.awt.Label; import java.awt.TextArea; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map.Entry; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class Fall_2017 {    public TextArea courseInput;    public Label textAreaLabel;    public JButton addData;    public Dialog confirmDialog;    HashMap<Integer, ArrayList<String>> students;    public Fall_2017(){    courseInput = new TextArea(20, 40);    textAreaLabel = new Label("Student's data:");    addData = new JButton("Add...

  • JAVA problem: Upgrade and extend the previous programs Draw.java and DrawCanvas.java used in the class to...

    JAVA problem: Upgrade and extend the previous programs Draw.java and DrawCanvas.java used in the class to maintain a list of shapes drawn as follows: Replace and upgrade all the AWT components used in the programs to the corresponding Swing components, including Frame, Button, Label, Choice, and Panel. Add a JList to the left of the canvas to record and display the list of shapes that have been drawn on the canvas. Each entry in the list should contain the name...

  • Hello I am having trouble with a connectFour java program. this issue is in my findLocalWinner...

    Hello I am having trouble with a connectFour java program. this issue is in my findLocalWinner method, it declares a winner for horizontal wins, but not for vertical. if anyone can see what im doing wrong. public class ConnectFour { /** Number of columns on the board. */ public static final int COLUMNS = 7; /** Number of rows on the board. */ public static final int ROWS = 6; /** Character for computer player's pieces */ public static final...

  • This is java. Goal is to create a pacman type game. I have most of the...

    This is java. Goal is to create a pacman type game. I have most of the code done just need to add in ghosts score dots etc. Attached is the assignment, and after the assignment is my current code. import java.awt.Color; import java.awt.Dimension; import java.awt.Image; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.io.File; import java.io.FileNotFoundException; import java.util.Arrays; import java.util.Scanner; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; public class Maze extends JFrame implements KeyListener { private static final String[] FILE = {...

  • This is my code for a TicTacToe game. However, I don't know how to write JUnit...

    This is my code for a TicTacToe game. However, I don't know how to write JUnit tests. Please help me with my JUnit Tests. I will post below what I have so far. package cs145TicTacToe; import java.util.Scanner; /** * A multiplayer Tic Tac Toe game */ public class TicTacToe {    private char currentPlayer;    private char[][] board;    private char winner;       /**    * Default constructor    * Initializes the board to be 3 by 3 and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT