Menu
  • HOME
  • TAGS

Tic Tac Toe Checking winner

java,tic-tac-toe,jcreator

Two things to do (generally speaking): 1) change your main class - you are checking winner before first move and after last move... So game for should looks like this: for (i = 0; i < 9; i++) { if (KollaVinst(spelplan)) { break; } else { CheckMove(spelplan, rad, kolumn); }...

The mean and the standard deviation of the values in its array parameter

java,jcreator

To generate the mean value, add up all values in your list and devide them by the number of values: public static void meanArray() { double result = 0; for(int i : list) { result += i; } result /= list.length; System.out.println(result); } ...

java Parameter index out of range (1 > number of parameters, which is 0 with mysql - simple login

java,mysql,jcreator

I just needed to change the SQL query string to below in order to pass the parameters! Doh! String sql = "SELECT * from operators where user_name = ? and pass_word = ?"; ...

Code for only accepting integers

java,jcreator

Put your input request in a while statement, check if it's an int, if not repeat the loop, otherwise exit. Do it for both your inputs. Something like this public static void main(String[] args) { String input=null, inputs=null; int input1 = 0, input2=0; boolean err=true; do{ try{ input = JOptionPane.showInputDialog("Enter...

Text game. How to use a bag?

java,class,jcreator

I would create a class Bag with two Items public class Bag { Item item1; Item item2; } public class Item { <any item properties here> } ...

Choosing an arrays size and populate it with user input

java,arrays,jcreator

Try the below code to take the array size from user and then user input elements: public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("Hur många nummer ska din lista bestå av?"); int ListaLength = s.nextInt(); Integer array[] = new Integer[ListaLength]; for (int i = 0; i < ListaLength;...