// 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.
in javafx, how can i implement a composant as shown in the following figure. when i click in the arrow, i must have a menu allows me to do a multiple choice like shown in figure
I have to write a short quiz that consists of 3 multiple choice questions. When the question is answered wrong I have to get it to loop back and ask the same question until the question is answered right.
I think I have the majority of my variables assigned and I have the scanner set up.
System.out.println("Question 1- Which TV sitcom recently had it's 20th anniversary?"); System.out.println("1. Two and a half men " + question1 + ".Friends 3.The Fresh Prince of Belair h.Get a hint"); answer2 = stdIn.nextInt(); if (answer2 != question1) { System.out.println("Your answer was incorrect, please try again or pick h for a hint"); } else { }
Create a java application that contains an array of 10 multiple-choice questions related to you favorite hobby. each question contains three answer choices. also create a parallel array that holds the correct answer to each question - A,B, or C. display each question and verify that the users enters only A,B, or C as the answere - if not, keep prompting the user until a valid response in entered. If the user responds to a question correctly, display "Correct!"; otherwise, display the correct answer is and the letter to the correct answer. After the user answer all the question, display the number of correct and incorrect answers.
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;
I am a begMy task is to write a program that plays the "Hi Lo guessing game." The program runs smoothly. However, it does not proceed to the next game after the previous game is done. I need to add a "play again" choice to the program so that the user will continue to play until they have chosen to quit. I have tried several different ways but each one has failed. I am completely stuck on this. I have attached my code to this.
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;
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.
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.
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.
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.
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;
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.
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 ...
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");
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 ) }
I have i am trying to implement tooltip through javascript, like when we click on an image link tooltip should be displayed and it should have close button/ close image to close that tooltip.like the same way i will have multiple images on page, when ever i click on the images all tooltips should be displayed on the page when ever i want to close that then only it should close through close button on tooltip.can we do it through java script or will go for jquery.
I'm very new to Java, and I am creating a program that takes multiple user input to create one face. I have a class for the eyes, nose, lips, and headshape. For some reason, my program is not drawing the graphics. ***for question purposes, I have only included my head shape class and my test class****
my "test" class:
import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; public class FaceTest { public static void main(String[] args) { String head = JOptionPane.showInputDialog("Would you like a circle, square, rectangle shaped head?: ");
I have some class called sorted to sort the linked list through the nodes of the list. and other class to test this ability, i made object of the sort class called "list1" and insert the values to the linked list.
If i make other object called "list2" and want to merge those two lists by using method merge in sort class. And wrote code of
list1.merge(list2);
How can the merge method in sort class know the values of list1 that called it as this object is created in other class.
I have a list of 100,000 + names and I need to append to that list another 100,000 names. Each name must be unique. Currently I iterate through the entire list to be sure the name does not exist. As you can imagine this is very slow. I am new to Java and I am maintaining a 15+ year old product. Is there a better way to check for an existing name?