Electric Bandit Machine Coding

Jan 8, 2015

I am required to create an electronic bandit machine that can display all images and buttons, user can input money, random display of images, machine stop when money runs out, user can put money in and start again and also a display of winnings. So far The user can input money and this is added to their bank however when the spin button is clicked no shapes appear despite their being a selection of images. My code is below.

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.*;
import javax.swing.Timer;

[code]....

View Replies


ADVERTISEMENT

Networking :: Connecting To Remote Windows Machine From Local Machine Using SSH2

Apr 11, 2014

I have developed a code to connecting remote windows M/C from local M/C by using SSH2 (ganymed-ssh2-build209.jar) API. when I run the code its giving below error. Is there any other way to connect remote windows system using java code.
 
Exception.
 
java.io.IOException: There was a problem while talking to <host name>:22
  at ch.ethz.ssh2.Connection.connect(Connection.java:642)
  at ch.ethz.ssh2.Connection.connect(Connection.java:460)
  at Connect.RemoteServer.ConnectWindowsServer.runCommand(ConnectWindowsServer.java:55)
  at Connect.RemoteServer.ConnectWindowsServer.main(ConnectWindowsServer.java:27)
Caused by: java.net.ConnectException: Connection refused: connect

[Code] ....
 
JAVA Code

import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.Session;
 public void setAuthenticationInfo(String hostname, String username,String password) {
       this.host = hostname;
       this.userid = username;
       this.password = password;      
       this.recentCommand = "";     
       System.out.println("setting authentication info completed for host=" + host );
 
[Code] .....

View Replies View Related

Java Code To Access Windows Machine From Unix Machine

Feb 28, 2014

I have a requirement where I have to send a file from a local system to unix box(present on client side) using java code.I have developed a code that is successfully sending the file from local system to client side unix box (I am connecting to client side unix box using VPN) provided I run the code in my eclipse IDE present in local system. But when I am running the same code in the unix box it is throwing null pointer exception.Might be the unix system is not recognising the local system. Please find the code.
 
package abc;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.Properties;
import com.jcraft.jsch.Channel;

[Code] ....

Error on unix box which I am getting is :-
 
Inside sftpConnection method
llllllll
fffffffffffff
Connection Successfull
Channel Connection Succesfull
aaaaa
Inside findFile method
Exception in thread "main" java.lang.NullPointerException
        at abc.TranferFile.sftpConnection(TranferFile.java:58)
        at abc.TranferFile.main(TranferFile.java:21)

View Replies View Related

Coding A Coinage

Sep 26, 2014

Listed below is the program I put together for class. I followed all of the instructions ....

import java.util.Scanner;
public class coinageJones{
int quarter = 0;
int dime = 0;
int nickel = 0;
int penny = 0;
int current = 0;
int original = 0;
int remainder1 = 0;
int remainder2 = 0;
int remainder3 = 0;
int remainder4 = 0;

[code]...

View Replies View Related

What Is The Coding For Udp Port Scanning

Feb 3, 2014

what is the coding for udp port scanning?

View Replies View Related

Avoid Deadlock While Coding

Jul 25, 2014

is it possible to avoid deadlock while coding..

View Replies View Related

Coding Own Classes - If Condition?

Jun 9, 2014

public int getIndexOfAMonster(String nameToGet){
int retValue = -1; //default is not found
for (int i = 0; i <= numberOfMonsters - 1; i++)
if (monsters[i].getName().equals(nameToGet))
retValue = i;
return retValue;
}

1.What does the if-condition do?If the name of a monster in the array is equal to the name stored in the variable, return the monster's assigned value.

2.What does the for loop do? The loop condition simply loops through the whole arraylists. (In other words, it simply checks each Monster contained in the lists).

3.Assuming that the driver code compiles, explain what it’s use is? If the name of the monster is the same as the variable passed unto this method, return the number assigned to that Monster.

View Replies View Related

Coding AI Game Through Java

Apr 10, 2015

The game has two players: x and o. The players take alternate turns, with player x moving first at the beginning of each game.

Player x starts at position (1,1) while o starts at (8,8).

Each turn, a player can move like a queen in chess (in any of the eight directions) as long as her path does not cross a square already filled in or occupied. After moving, the space vacated by the player is designated as filled and cannot be moved to again. Notice that only the space that was occupied is filled, not the entire path.

The game ends when one player can no longer move, leaving the other player as the winner.

The coordinate (1 1) indicates the top left hand side of the board.

The board is specified as a list of rows. Each row is a list of entries:

- is an empty square * is a filled in square x is the current position of the x player o is the current position of the o player

The board will always be 8 by 8.

Your player function should take in the parameters as described above and return a move as a list in the format (row column) within 1 minute. If you cannot move, return (nil nil). The Tournament Referees will check for this. If you return an illegal move, the other player (and the Tournament Referees) will detect it and you will lose.

Additionally if your time expires you will lose.

View Replies View Related

Java Coding For Block Division

Feb 7, 2014

I'm doing project in area of "Cryptography and Network security". I'm having a file with binary Unicode (mean file contain Unicode value of corresponding data (text file)), want to divide that as blocks with the size of 144bits.

View Replies View Related

Eclipse - Coding Multiple If / Else Statements

Apr 22, 2015

What I am attempting to program is a simple Boss battle. I would like the user to have 2 options (for now): Run, or Attack. I got the portion completed and working, but once I tried to implement the Run feature (the way that it's supposed to work is you can either attack OR run), both Attack and Run will happen. Also, for some reason, the running always fails (it will always return the else statement, then move onto the attack.) Here's my code:

import java.util.*;
public class AdvancedBossBattle {
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
Random gen = new Random();
int bosshp, bossdmg, playerhp, playerdmg, runChance;
String answer;
bosshp = 100;

[Code] ....

View Replies View Related

Make A Circle With Java Coding

Aug 12, 2014

i want to make a circle with java coding.... i tried but i am grtting some error...

View Replies View Related

Java Coding For Constructors And Input

Oct 25, 2014

I was required to make a program that contains 3 data fields, 2 constructors, and 4 methods. I'm having a hell of a time trying to put some input into this, where the user would choose from 1 of the 3 data fields I made up for car prices and choose their vehicle. As far as the constructors go, I made a default one but I'm not sure on how to A) implement another constructor and how do I involve the input into this and C) where the methods go in that.

I'm thinking of putting the input first but that ruins my constructors? I realize I asked a lot, but this is an online class without a text, and I'm basically starving for knowledge. [code]

public class Vehicle{
int truck;
int car;
int van;

[code]....

View Replies View Related

Sieve Coding Not Pairing In Output

Apr 1, 2015

When I compile the code, it goes through fine in the compiler. However after entering the boundaries for the lower an upper it doesn't produce the prime pairs between the two boundaries that the user sets. I have tried changing some of my integers that i initialized no luck. I looked at the last section of public void showPrimes() . However I can't seem to see where it has gone wrong there. I have included the entire code, plus the section again that I think is wrong. I have also posted the final output of what it looks like and what else should be included to make it easier to see what I am missing. Basically it keeps giving me zero primes even when the boundary is 100 and 200, or so and so forth.

import java.util.Scanner;
public class kbeaudry_xSieve
{
public static void main (String args[]){
kbeaudry_xSieve i = new kbeaudry_xSieve();
}
boolean primes[] = new boolean [50001];
int upper;
int lower;

[code]....

This is what i get when I actually run the program. However in the section where I have added *****, this is where it should put the prime pairs in.

Please enter a lower boundary and an upper boundary and I will print all of the sexy prime pairs between those boundaries.
Please enter the lower boundary (between 1 and 50000): 200
Please enter the upper boundary (between 1 and 50000): 600

There were 0 sexy pairs displayed between 200 and 600.. I am still working on another code for my that I had issues with, however I had to go out of the country for a few days to take care of some work.

View Replies View Related

Coding A Robot To Follow A Line In Eclipse?

Mar 11, 2014

I have a serious issue with getting this robot to follow a line?

View Replies View Related

How To Read USB Signal Values Through Java Coding

Apr 15, 2014

how to read a usb signal values through java coding

View Replies View Related

Fading Trail And Random Movement Coding?

Oct 30, 2014

I need the following key controlled ellipse to leave a trail behind that vanishes after 10 frames. Also, I need to create a random moving ellipse not related to the preexisting one. How to separate the two ellipses ...

Current code:

boolean left, right, backward, forward;
boolean SPEED;
 PVector pos = new PVector(680, 400);
 void setup() {
size (680,400);
fill (0 ,0,0);
frameRate(100);
noCursor();

[Code] .....

View Replies View Related

Coding Multiple-choice List Dialogs

May 15, 2014

// create an AlertDialog Builder and set the dialog's title
AlertDialog.Builder regionsBuilder = new AlertDialog.Builder(this);
regionsBuilder.setTitle(R.string.regions);
// replace _ with space in region names for display purposes
String[] displayNames = new String[regionNames.length];
for (int i = 0; i < regionNames.length; ++i)

[Code] ....

From the code above, An alertdialog would pop up prompting the user to select a region (from a list). the user will then be allowed to select multiple choices accordingly. If I choose to select anything, the app crashes. How to mitigate this problem?

I know that I have to use a conditional check like if (isChecked){}; but I don't know how to do it. I want it to pop up a dialog box when none is checked prompting them that they should select atleast one.

View Replies View Related

Servlets :: Unable To Provide Name To Downloaded Files In JSP Coding

Mar 25, 2014

I wrote a code to download a zip file in jsp, but it is not working as expected, when i execute this following program i am able to download file with "download_all.jsp" name, but now original download file (/tmp/Download_All/1244687508907.Zip). The download_all.jsp is my jsp name which is having the following code. Here is the code snippet:

try {
String filename = "/tmp/Download_All/1244687508907.Zip";
if(request.getParameter("filepath")!=null){
filename=request.getParameter("filepath");
}
// set the http content type to "APPLICATION/OCTET-STREAM
response.setContentType("APPLICATION/OCTET-STREAM");

[code]....

View Replies View Related

Game Coding - No Enclosing Instance Of Type Background Is Accessible

Dec 11, 2014

So I'm fairly new to java and have been learning game development. I've come across this error message on my StartingClass.java coding. Here is the Coding

@Override
public void start() {
bg1 = new Background(0,0); // This line is giving me the error!!!!!!!!!!!
bg2 = new Background(2160, 0);
hb = new Heliboy(340, 360);
hb2 = new Heliboy(700, 360);
robot = new Robot();

Thread thread = new Thread(this);
thread.start();

The error reads "No enclosing instance of type BackGround is accessible. Must qualify the allocation with an enclosing instance of type BackGround (e.g. x.new A() where x is an instance of BackGround)." Now I have seven classes in my in my games src folder and none of them but the StartingClass.java has the error. Once again I'm fairly new to java and have not benn able to fix it.

These are the classes{

BackGround.java
Enemy.java
Heliboy.java
package-info.java
Projectile.java
Robot.java
StartingClass.java ( errors in this class )
}

View Replies View Related

JSF :: Passing Session To Different Machine

Aug 4, 2014

In my JSF application user starts on primary server where the session begins and then the user is redirected to a different server using sendRedirect. I want to pass some authentication token to the next server from primary server. I am trying to set session attribute as:

request.getSession().setAttribute("auth_token", "1");

And then send it to the next server as:

response.sendRedirect(encodedUrl);

But this attribute is not reaching the new server. I cannot pass this auth_token as request parameter as that wont be secure. So how to get some session data to new server?

View Replies View Related

ATM Machine - Action Listeners

Mar 27, 2014

My output is all over the place. I cancelled out the borderlayouts beneath each panel I created and it completely changed the output, and I'm not sure why. The first photo below, shows what it looked like with the layouts and the second shows the output without. I still don't understand why I don't see the digits 1-9.

Java Code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
public class Atm extends JFrame {
Atm(){
super("ATM");
//Create Panels For ATM
JPanel buttonPanel1 = new JPanel(); //To Contain Digits 1-9

[Code] ....

Why would setting the layout beneath each object change the layout so much? I stayed consistent in my use of BLayout and GLayout in the program.

View Replies View Related

What Is Java Virtual Machine

Mar 5, 2014

What is Java Virtual Machine (Java VM)?

View Replies View Related

Vending Machine - Different Files

May 1, 2014

keep getting an error when inventory is printed out. wont carry the money over. cant find out how to do it?

[import java.util.Scanner;
public class VMachine
{
Scanner input = new Scanner (System.in);
double candy;
double soda;
double dsoda;
double money;

[Code] ....

View Replies View Related

JCreator Slot Machine

May 18, 2014

I pulled off an all nighter in order to finish off this project for my computer studies class but i keep getting an error cannot find symbol at line 96?

import java.io.*;
import java.util.*;
import java.util.Random;
public class SlotMachine {
//Generates 3 random numbers for slot machine
public static void main(ArrayList<Integer> slotMachine) {

int count = 0;
while (count<3)

[code]....

View Replies View Related

Create ActionListener For ATM Machine

Mar 28, 2014

I've scanned the book and a few other forums trying to find an answer to my particular question (or I simply didn't understand) with no luck. I want to create an ActionListener for my ATM machine, that will both receive the input numbers to check them against the passcode for a predefined user, but also add the typical " * " that we see when performing such an action.

1. I have created individual objects for each button, which I then used in the constructor "perform" from class action. I'm not sure where to start in the method ActionPerformed.

2. How do I get the asterisks to appear in the JPasswordField each time a numeric button is pressed on the keypad?

Java Code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Atm extends JFrame {
Atm(){
super("ATM");
//Create Panels For ATM
JPanel buttonPanel1 = new JPanel(); //To Contain Digits 1-9
buttonPanel1.setLayout(new GridLayout(4,3));

[code]....

View Replies View Related

State Machine Compiler

Oct 19, 2014

I am working in software testing, specifically automatic test cases generation. Among the existing forms of test cases, my focus is on the test cases that are composed of sequences of events such as _.event1.event2 eventx()

However, the events can be classified into: sensitive and insensitive. The latter does not affect the system's states, and hence, it can be ignored; while the former affects the states. Anyhow, the sensitive events in the test cases may lead to states explosion and there is a need to prevent that. Therefore, some techniques suggest using one variable to present states and group all similar states together such as using len variable in circular queue. Relatively, the states can be represented by using specific drawings such FSM.

For example, the test cases for circular queue may look like:

add(0).remove().add(1).Front()
add(0).add(1).remove().Front()

which produce the following states:

len=1, rear=0, front=0 and dataQ[0]=0
len=0, rear=0, front=1 and dataQ={0}
len=1, rear=1, front=1 and dataQ[1]=1

len=1, rear=0, front=0 and dataQ[0]=0
len=2, rear=1, front=0 and dataQ[1]=1
len=1, rear=1, front=1 and dataQ={1,0}

As can be seen, every addition/deletion produces a new state. A state is composed of 4 variables: len, rear, front and dataQ. The 1st three variables are integers while the dataQ is an integer array. Nonetheless, the states produced by different test cases can be identical which wastes effort and time. So, there is a need to optimize these states. The search techniques were suggested where the problem can be represented as a search problem and the technique is applied. If we consider Len as a state, then we will have: len=0; 0QSize. However, this does not represent the state but it suits for classifying the states into groups.

In terms of states representation, State Machine/Map Compiler (SMC) was suggested as a modeling mechanism that takes the state machines (i.e. FSM) drawing and generates the code in any preferred language. In SMC, the FSM is represented in a specific syntax (state---transition----next state) and saved in a file (.sm). This file will be compiled by SMC to generate a context class which includes definitions of states, transitions and actions in FSM but still need to be triggered by another class. This class has to call the transitions that modifies the state.

We had created that class and implemented all the methods with their transitions. However, the FSM used was based on 1 variable only (i.e. len). Besides, we are still looking for the SMC results as they will be the input for any search technique to be applied. Supposedly, the states generated by SMC can be used directly in the search technique but this is still questionable.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved