Text Adventure - Cannot Use Menu Selection

Apr 30, 2015

I cannot use menu selection 4 5 6 7 8 9 10 ... Why NO_EXIT has been declared and used in defining the contents of the map array, rather than just directly using the value 99999 in the map array definition

I don't understand map[][], objectName[] and objectLocation[]

package Assignment;
import java.util.Scanner;
public class GameWorld
{
// the map array holds details on which paths lead to which other rooms. NO_EXIT indicates no valid exit.
// each element holds the details of all paths leading out from a single-room in the order n ,e, s, w, ne, se, sw, nw
private final int NO_EXIT = 99999; // indicates that there is no exit in that direction
private int map[][] ={{NO_EXIT,NO_EXIT,NO_EXIT,1},{2,0,NO_EXIT,NO_EXIT},{NO_EXIT,3,1,NO_EXIT},{NO_EXIT,NO_EXIT,NO_EXIT,2}};

[Code] .....

View Replies


ADVERTISEMENT

Text Adventure Game

Jul 19, 2012

I'm creating a text adventure game, but there are some bugs in it that can get annoying such as restarting the program when it shouldn't be, going to the wrong piece of text, etc.

Java Code:

import java.util.Scanner;
public class Act_1 {
/**
* @param args
*/
public static void main(String[] args) {
boolean again = true;
do{
int option;
Scanner input = new Scanner(System.in);

System.out.println("You are Paul Soares Jr, an expert survivalist who has been caught in the midst of a zombie apocalypse in the land of MineZ. You awaken in a dense forest with a lake nearby. In your backpack you have a wooden sword, a pack of matches, one torch, some snacks and meals, a H.A.M. radio, a full water bottle, and a bandage.");

System.out.println("");//the "" adds a space in the text
System.out.println("Do you: ");
System.out.println("");
System.out.println("<1> Head inland");
System.out.println("<2> Stick close to the water");
option = input.nextInt();

[code]...

View Replies View Related

Java Text Adventure Game - Adding Characters

Apr 14, 2014

I am making a java text adventure and i am trying to add characters to it. I wrote it exactly the same as i wrote the items class (which works fine) but for some reason the character class keeps getting a null pointer exception when it gets to line 140 in the room class

characters.add(c);
game class
import java.util.ArrayList;
import java.util.HashMap;
/**
* Game class for Free Willy Five: an exciting text based adventure game.
*

[Code] ....

View Replies View Related

JSP :: How To Display Only Text File In Selection Window

Apr 7, 2014

I am trying to upload the text file in specific location in my disk but when I open selection window it displays all type of files while it should display the files only having .txt extensions

I am writing the code below,

<%@page import="org.apache.commons.fileupload.*,java.util.*,java.io.*"%>
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<%
// JSP to handle uploading
// Create a new file upload handler

[code]....

View Replies View Related

Swing/AWT/SWT :: How To Fill Text Fields With Selection From JList

May 2, 2015

I have an addressBook GUI where I have a JList that populates with the contacts names, and once I double click a contacts name I'm wanting to fill the textfields with the contacts corresponding data.

ex) ContactType: Family (enum), Name: Zoidberg, Address: 111 Space Drive, City: New York City, etc...

I've got it to where I select open from the JMenu, it populates the JList, but once I select a contacts name, all the textfields are populated, but only with the contacts name

ex) Name: Zoidberg, Address: Zoidberg, City: Zoidberg, etc....

What am i doing wrong here, and how can i fix it to where it fills out the correct data?

Here's my code so far:

public class AddressBookGUI extends JFrame {
private final int WIDTH = 450;
private final int HEIGHT = 300;
private JLabel currentlySelected;
private JTextField contactTypeTextField;

[code]...

I'm certain the logic is messed up near the end where i set all text fields to the index, because no matter what field i want to fill it's at it's going to set it to whatever index I select, but I don't know how to fix it.

View Replies View Related

Dinner Menu Program - Some Text Is Not Showing On Applet

Dec 23, 2014

I have been writing the below Dinner Menu Applet; however some text is not showing on the applet and it is not adding the 'desserts" section correctly especially the one that says "rice Pudding". I've tried it in so many different ways and it's sill not working correctly.

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class DinnerMenuApplet extends Applet implements ItemListener
{
Label dinnerMenu = new Label("Dinner Menu");

[code]....

View Replies View Related

Populate A Table With User Input Text And Selection From A Combo Box

Dec 4, 2014

I need to populate a table with user input text, and selection from a combo box.

View Replies View Related

Reading Json Of Nested Menu Without Giving Menu Names In Java

Aug 14, 2014

I want to read json file as follow;
 
{
  "M": {
  "row": [
  {
  "col1": "c00"
  },
  {
  "col1": "c10",
  "col2": "c11"
  },
  {
  "col1": "c20",
  "col2": "c21",
  "col3": "c22"
  }
  ]
  }
}
 
Next to reading I need to assign to two dimensional array, but without giving "col1","col2","col3" a lot. 

The array is for example, Array[3][] = {{"c00"},{"c10","c11"},{"c20","c21","c22"}};

View Replies View Related

Creating Simple Text Editor - Delete Selected Text Inside Text Area

May 13, 2015

This is the code that I wrote but I have two problem with two buttons one of them ... I want to delete the selected text inside the text Area which represented as b[8] and the other button that I want to select parts of the texts which represented as b[0]....

Here is the code..

package KOSAR2;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;

[Code] .....

View Replies View Related

How To Create A Menu

May 12, 2014

I'm trying to create a GUI java application.

I want a menu with buttons that looks like this:

Button 1: Start
Button 2: Help
Button 3: About Me

If you press one of the buttons you will get to another frame with new buttons, new labels and so on.

Next step for instance if you press button 1, I'd like my program to get this frame:

Different alternatives, and a text field with a button. One commando leads to one new JFrame with new buttons, text fields and so on.

View Replies View Related

Pickup Selected Text File And Read Line By Line And Output Text Into Visual Text Pane

Dec 12, 2014

I am checking how to do following task.

01. pickup the selected text file and read the line by line and output the text in to visual text pane.

what i did:.

01. I wrote code that read the text file and output in to jave console/ also some of the interface.

the code read txt file:

Java Code:

String fileName = "C:/Users/lakshan/Desktop/lawyer.txt";
File textFile = new File(fileName);
Scanner in = new Scanner (textFile);
while(in.hasNextLine()){

[code]....

so it will read any text file dynamically and output to the text pane in interface. I think scanner code must be execute after the select the file from the browser and set the scanned result in to variable. then later out put the var as string in some jswing component?

View Replies View Related

Recursive Selection Sort

Oct 21, 2014

How would I modify this version of a selection sort into a recursive method?

public static void selectionSortRecursive(Comparable [] list, int n)
{
int min;
Comparable temp;

[code]....

View Replies View Related

Using Multiple Selection Choices?

May 28, 2014

This program allows the user to select one of each different type of skateboard/accessories items. Then it allows the user to select as many misc items as he or she chooses. The program works fine for the single choices, but I cannot solve the latter part. I have a get method in the misc class that is trying to pull out any selection or selections that were made by the user, but it simply does nothing...

Here's my program, I have four panel classes for each skateboard type, and then I have one class that takes care of adding each panel to the content pane, and calculating the total cost of the item.

Decks Panel Class:

import java.awt.event.*;
import javax.swing.*;
// The DecksPanel class allows the user to selects a specific type of skateboard
public class DecksPanel extends JPanel

[Code]....

View Replies View Related

Selection Sort Method?

Mar 5, 2014

I'm trying to make a selection sort method that will sort a list of Strings alphabetically.

I have a test list of Strings like so:

Joe, Steve, Oscar, Drew, Evan, Brian, Ryan, Adam, Zachary, Jane, Doe, Susan, Fred, Billy-Bob, Cindy, Mildred, Joseph, Hammer, Hank, Dennis, Barbara

However, whenever I run the method, the element that should go last, Zachary, in this case, ends up getting moved to the front for some reason. I'm not sure why.

I tried changing what the first element was initialized to, to the variable i as that would logically work as well, but it ends up missing the first element in the list.

Java Code:

public static void selectionStringAscendingSort (String[] words){
int i, j, first;
String temp;
for ( i = 1; i < words.length; i++ ) {
first = 0; //initialize to subscript of first element
for(j = i; j < words.length; j ++){ //locate smallest element between positions 1 and i.
if( words[ j ].compareTo(words[ first ]) <0 )
first = j;
}
temp = words[ first ]; //swap smallest found with element in position i.
words[ first ] = words[ i ];
words[ i ] = temp;
System.out.println(Arrays.toString(words));
}
System.out.println(Arrays.toString(words));
} mh_sh_highlight_all('java');

View Replies View Related

Selection Does Not Contain A Main Type

Mar 23, 2014

I'm trying to run a simple code which is to just print out "Hello World", but whenever I run it, a message appears that reads: "Select a way to run Project_1(Which is the Java Project)"

The selections for it are: Java Applet and Java Application.Whenever I click Java Applet it reads: Selection does not contain an applet.When I click Java Application: Selection does not contain a main type.Here is the code which I believe is correct:

package packag_1;
public class Num_1 {
public static void main(String args){
System.out.println("Hello World");
}
}

View Replies View Related

Design Pattern Selection

Mar 27, 2015

I need selecting which design pattern to use in my case.

I am creating a list of objects "items" to be presented in a list for the user to choose from, all objects have a title and a check box. Some objects have additional textbox for user input, some objects have additional image for illustration, and some objects have additional textbox and image as well.

I read and saw online videos but not sure if my selection "Factory Design Pattern" is the best match.

View Replies View Related

JSP :: DropDown Menu Does Not Work

Nov 17, 2014

I want to create a dropdown menu with contents from a database. You can see my Code in the attachment. It does not work, but why? I have a dropdown-symbol, but no contents.

View Replies View Related

How To Change Menu GUI With Buttons

Apr 23, 2014

I have a GUI with a menu to do various options. However I want to change that menu to use buttons instead. I'm working with JSwing components and I'm a little familiar with the JButton function, but I don't know how to convert the menu to a button. I think I'll have to remove the menu completely..anyway I tried to start with the file menu but the compiler says no suitable method found for setForeground(javax.swing.JMenu). Why is it giving me an error related to JMenu when I'm using Jbutton objects? Can I not use JButton objects inside a menubar scope? I'll bold the area it highlighted:

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

[Code]...

View Replies View Related

Cannot Display Menu Using Derby

Apr 15, 2014

ok so I am trying to create a movie rental database. I want to show a list of movies, customers, and rentals. my problem is that I cant run everything but I keep getting the following error :

ERROR: Table/View 'MOVIES' does not exist.

Here is my code

import java.sql.*;
import java.util.Scanner;
public class MovieRentalDB
{
public static void main(String[] args)

[code]....

the program runs but I keep getting that error. I know my code is also not complete but I will do the rest once I figure out why my tables are not creating

View Replies View Related

Using A Menu For Stack Operations

Dec 3, 2014

I am working on implementing a stack using a linked list. Programming the stack operations (push, pop, isEmpty, etc.) was easy but my directions were to provide the user with a menu to choose the operation that he/she wishes to perform. I am new to JFrames/Menus so how to make the stack operations available in a menu.

View Replies View Related

JSP :: Selected Drop Down Menu?

Nov 8, 2014

I am making an edit page and I want to populate my drop down menu with things that were already selected. For example, if i want i click to edit my favorite food it will be populated with the one the user previously selected. How do i go about doing this? [URL] ....

View Replies View Related

Creating A Menu For Grades

Sep 29, 2014

I have an assignment that I need to create a menu like this using only arrays.

Main Menu:

1. Input how many students.
2. Input names and grades
3. Print name and grades.
4. Exit

I dont know how to do them in array.

View Replies View Related

Applets :: 2 Jlists / Second One Depends On Selection In First One?

Jun 2, 2014

So I have an applet and in the first ScrollPane you have a number of options of businesses

The Centre

IMAX

etc ..

and when you click one , the other scrollpane shows office

so when i choose "The Centre" for example , in the right scrollpane it shows : "Head Str." "Downtown" etc

i can fill in the first scrollpane with:

void myInit() {
DefaultListModel model = (DefaultListModel)businessList.getModel();
model.removeAllElements();
try {
ArrayList<Business> bussinesses = contr.getBusiness();

[code]....

but this gives me a NullPointerException on

ArrayList<Office> offices= business.getOffices(name);

which i don't understand, since business isn't null .. it's the selected value.

View Replies View Related

Graphically Displaying Selection Sort

May 20, 2014

I am trying to write a program that graphically displays a selection sort. It needs to sort bars of various heights, and the bars heights are generated from an array of random integers. The program needs to show the bars swapping as they are being sorted, I am having trouble getting the bars to draw, it needs to look like a bar graph. Here is my code thus far (not counting my boiler plate):

import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
import java.awt.*;
import java.util.Random;
public class SelectionSortPanel extends JPanel

[Code] ....

Also right now it is giving an error from the compareTo method?

View Replies View Related

How To Do Selection Sort Of ArrayList By Customer Last Name

Nov 8, 2014

I have an arrayList with these values:

Mike Smith with a customer id of 100 has an account number of 1000 and a balance of $5,000.00
Hank Jones with a customer id of 101 has an account number of 1001 and a balance of $45,000.00
Sam Overstreet with a customer id of 102 has an account number of 1002 and a balance of $45,000.00
Hank Jones with a customer id of 101 has an account number of 1003 and a balance of $48,000.00
and so on .....

I am trying to do a selection sort by the account holders last name. I understand how to do if the Arraylist holds integers, but my arraylist holds multiple fields. I am not allowed to use collections as this is a homework assignment.

here is the Account Class

public class Account implements Comparable<Account> {
private int acctNum;
private double balance;
private Customer cust; // note we are putting a Customer object in the Account clas
private static int nextAcct = 1000;// used to keep track of the next available account number

[Code] ....

View Replies View Related

Graphic Array Selection Sort?

May 21, 2014

This is a lab for one of my CS classes, and the assignment is to create a randomly filled array (values 10-100) and use these values as the height of an array of rectangles (essentially a bar graph)that will be drawn on a page. After that's done, the code should use the selection sort method to sort the bars least to greatest, being repainted as it's sorted.

I'm receiving no errors, the original draws just fine, and the code sorts the first position and then...it just hangs. Like it's in an infinite loop but I have all of the modifiers in place (I think. I've been staring at this code for three days straight and I don't think I really see it anymore). I've tried talking to my professor and I get that her private life is really busy right now, but she just keeps blowing me off and I don't know what to do. Anyway, done with back story and whining so here's the code.

Rectangle class:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Rectangle

[code]....

View Replies View Related







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