I started with Eclipse and wrote the basic "Hello World" app and added a few other lines of a=5, b=9, println (a*b) etc. and ran the program in the screen.
Then I thought that perhaps I could move it onto my nexus 7 and see what it looks like there. [I have a lot to learn I suppose].
The first issue is that I can't connect my Nexus 7 tablet to me macbook pro without using "android file transfer" and then the computer does not show the device in the finder because it is running through the file transfer program.
I have done some research and changed the settings in the nexus to connect as a camera rather than storage but that doesn't work either.
So my main issue now is being able to get the program onto the device - can it simply be copied and pasted into one of the files on the device using the file transfer screen?
My code below is trying to make a connect four program without GUI. I'm having trouble with getting the players to make their moves. What should I put in my "makeAMove" method...
Java Code:
public class Connect
final static int MAXROW = 6; final static int MAXCOL = 7; public static void main(String[] args){
For the latest assignment, my instructor has asked us to create a program where we create lines of at least for integers and if the program registers there being four of the same integer horizontally, vertically, or diagonally it returns true. For example:
If the program doesn't see four integers of the same value anywhere, it is supposed to return false. I've got it so it returns true for the lines above, 6x6 lines of integers and lines where only four out of six+ integers are equal. However, I cannot get my code to return false if there are only three matching integers in a row/column/diagonal nor can I get the program to print out either true or false for lines that do not start at the top left corner. (i.e 2 3 1 1 1 1) For the former I get this error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4 at ConnectFour.is4Consecutive(ConnectFour.java:41) at ConnectFour.main(ConnectFour.java:32)
For the latter:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6 at ConnectFour.is4Consecutive(ConnectFour.java:43) at ConnectFour.main(ConnectFour.java:34)
The answer to fixing my code is probably something small or something that will make me wonder why I hadn't thought of it myself... Here is my code:
import java.util.Scanner; public class ConnectFour { private static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); System.out.print("Enter the height: "); int h = sc.nextInt(); System.out.print("Enter the width: ");
User-defined classes. The concept of getters and setters goes right over my head. Right now we're to write a program to test the Person class below. We have to create 2 instances of the class to test each constructor, and test each method.
class Person { // Data Members private String name; // The name of this person private int age; // The age of this person private char gender; // The gender of this person // Default constructor public Person() { this("Not Given", 0, 'U');
[code]....
then my output will print out the name. But the assignment doesn't tell us to modify the Person class at all, just to create a tester one.
I'm working on a homework assignment and I keep getting a compiler message this is the message
GradesAverage.java:44: error: variable totalgrade might not have been initialized System.out.println("Over all you have " + totalgrade); ^ 1 error
The homework is this Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores and then assign the values entered to the variables. The program should display the average of the test stores and the letter grade that is assigned for the test score average. Use the grading scheme in the following table:
Test Score Average Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F
This is my code
import javax.swing.JOptionPane; // Needed for JOptionPane class import java.util.Scanner; // Needed for the scanner class public class GradesAverage { public static void main (String[] args)
So in trying to create a circle class, and use the dimensions of that circle (radius, area, etc.) to prove it will equal pie and print (3.141592653589793). This is my code so far it and am getting an error in the last two classes. I know it has to do with Circle(Radius); in the 2nd class but whenever i call upon it, it is assigned to itself. And in the last class im not too sure how to put the B= new b(1,1).
[public class Circle { private double radius; public Circle() { radius = 0; } public Circle(double radius) { this.radius = radius;
I'm making a program for school that reads a text file with answers to a personality test and prints the temperament to an output file. Problem is, it sets the temperament for the first person to INFJ and then prints INFJ for the rest of the people too. My code is below, and the input file 'personality.txt' goes like this:
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program:
calculateAverage This method should accept five test scores as arguments and return the average of the scores. determineGrade This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale
Score Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F
System.out.println("Enter the first score"); test1 = keyboard.nextDouble(); System.out.println("Enter the second score"); test2 = keyboard.nextDouble();
I did a problem from my book which is "Write a method that displays an n-by-n matrix. Each element is 0 or 1, which is generate randomly. Write a test program that prompts the user to enter n and displays the n-by-b matrix".
So if a user would enter 3, and output could be 0 1 1 0 1 0 1 0 1
So here's my question... I was able to get the program to work in the way my book describes (by just writing the code in the class with the main), but for practice, I want to learn how to do this OOP-style...
I'm not sure how to do this, though, since the method is a void method, so I can't seem to call it within a toString method.
import java.util.Scanner; public class MatrixTest { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter an int"); int number = input.nextInt(); MatrixClass mc = new MatrixClass(number);
I use Eclipse (kepler version, with JDK 7) on MacBook Pro (Lion).I want to overwrite a line printed on my console. I used "" for that. I was expecting the cursor to go to the beginning of the line. Instead, it is going to the next line.
Four experiments are performed, each consisting of six tests. The number of test results for each experiment is entered by the user. Write a Java program using a nested loop to compute and display the average of the test results for each experiment.
You can run the program by entering the following test results:
I have just started learning about sockets and such... and i have created a chat program with a server and a client
server:
public class Server { private static ServerSocket server; private static Socket connection; private static PrintWriter pw; private static BufferedReader br; private static JTextField textOutput;
[Code] ....
so, everything is working fine . There is only one thing i would like to do now: make it so that i can run the server from my computer and then others can run the client from theirs and we will be able to chat . So I tried:
In the client code on line 56 is says:
connection = new Socket("localhost",7777);
So I changed "localhost",7777 to "myip",7777)
But when i run the server on my computer and run the client on another computer i get this error:
Why is the connection getting refused? is it for security reasons? so hackers cant connect to me or something? And is there a way to tell your computer to allow that client to connect?
Our assignment is to make a version of the classic 'Connect Four' game, where we need to construct a GUI that shows the current state of the game and instead of having a winner once a player has four chips in a row, the game needs to continue until no chips can be placed anymore.We currently get stuck in the GUI part. Running it right now results in a board with empty spaces only. Also after choosing a column to place, the board remains empty.
Our question: How do we get the board filled with the right color of chips at the right place?We know the 'ArcsPanel'-class (almost at the bottom of the code) is wrong, but we don't know what to do to make it right.
I am trying to learn how to connect to web sites using java. Someone suggested that I learn to "consume an API with java". They also suggested that I practice through a weather website called weather underground and sent me a link [URL] .... I would like to know how to connect to this site to get weather information.
soo, is there a way to (via sockets or something like that) connect to a stream via the streamers url (or just via anything) and then get the actual stream? like the images that keeps updating? so that i can display the images/stream on a jframe?
How can I connect to an SSH server in Java? I don't need/want a shell. I just want to connect to the SSH server and get the content of, say, file.txt. How can I do that? Example : I get host, user,pass in txt and connect it with java code!
I have a vps set up to running a MySQL database already by zpanel but when I try to connect to the database with Java I am unable to connect and receive the message:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."
I have MySQL Connector(dev.mysql.com/downloads/connector/j) already added to my build and tried it with both the url and the ip. This is my connection code:
package net; import java.sql.*; import javax.swing.JOptionPane; public class LoginDatabaseConnection { Connection conn = null;
[Code] ....
The code is from youtube but when I connect to localhost it works fine however when I try to connect to the VPS the above error happens.
I am a student in an intro to computer science class working on my final project. This is essentially a game of connect 4, but only requiring 3-in-a-row for victory. We were given the base game and a sample file to work with to make an AI that beats our professor's ai in the base game. Here is the base game
I am having a problem to connect my .exe file to the database(mysql). I used launch4j to convert the jar file to .exe but the jar file can connect to the database when running inside the dist folder. When I run the .exe I am getting this error: No suitable driver found for jdbc:mysql.