Win a copy of Rust Web Development this week in the Other Languages forum!

David Hunt

Greenhorn
+ Follow
since Oct 13, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Hunt

I have the following information about a game which I have to extend for a tutorial question at Uni. Its for a console based game, where you move the character from square to square. I have to extend it. Looking at the information below about the IOracle interface for the game how would I go about writing a piece of code to search the tile (ie use the metthod required)?
Please note I don't want anyone to write all the code(but you can if you want), just to show me how it would be done.
Thanks
----------------------------------------------------------------------------------
public interface IOracle
The IOracle interface exposes the methods for obtaining pertinent information about the underlying Game World data model. The ITile documentation discusses the role of the tile within the Game World API and how this interface ITile provides its pertinent methods for exposing details of tiles. In addition, the ITileSearchResult documentation provides details of what is returned from the searching methods:
searchTileAt(int, int, int)
searchTileAt(Point, int)
searchAdjacentTo(int, int, int)
searchAdjacentTo(Point, int)

Obtaining An Interface To The Current Game World Oracle
An IOracle interface to the underlying OracleImpl object is obtained through the static method
OracleImpl.obtainOracle(boolean)
by passing boolean false to this method as the rebuildWorld argument. If no OracleImpl object has been previously instantiated, then the
OracleImpl.obtainOracle(boolean) method will act as a factory and instantiate a new OracleImpl object, returning an IOracle interface to this object. Use of the parameterless method OracleImpl.obtainOracle() acts in the same way as calling the parameterised version of the method with the rebuildWorld argument set as boolean false.
Passing boolean true as the rebuildWorld argument to OracleImpl.obtainOracle(boolean) will force the instantiation of a new OracleImpl object, discarding the existing one.
There are two distinct ways to interrogate the Game World through the IOracle interface. Firstly, pertinent details of the Game World tiles can be obtained through the getTileAt(int, int), getTileAt(Point), getAdjacentTo(int, int), getAdjacentTo(Point), getLineOfSight(int, int, int) and getLineOfSight(Point, int). All these methods require either an (x, y) coordinate passed as separate integer arguments or passed as a Point object. In addition, the line of sight methods require an integer visonRange argument. This visonRange argument specifies the maximum distance to see from the coordinate passed in the first arguments as a radius.
When a single ITile or ITileSearchResult interface is returned by one of the above methods, then this interface is for the ITile or ITileSearchResult interface at the coordinates passed as arguments into the methods. Methods that return a single ITile or ITileSearchResult interface are:-
� getTileAt(int, int) and getTileAt(Point)
� searchTileAt(int, int, int) and searchTileAt(Point, int)
17 years ago
Has anyone got any idea how to go about this or websites to show me as I do not know where to start.
Thanks.
18 years ago
I'm tring to do a multi threaded program suitable to run on two or more CPU's -so the first one.
The type of thing that helps share the load over a network(although the program I am using isn't anything heavy for the processor, this is just to test that it works.
18 years ago
I am looking to try and see if I can get a concurrent program running as I never have done so before and I am currently in a place with 10 computers on a network to try a program out on. So could someone convert this program that I have been working on(below) to be run concurrently using multithreaded java or show me another concurrent program so I can test out whether it works here, so I can start writing some myself.
Thanks
-----------------------------------------------------------------------------
import java.io.*;
class PrintMatrix
{
public static void main(String[ ] args)
{
PrintMatrix theApp = new PrintMatrix();
theApp.run();
}
private void run()
{
int[][] b = new int[5][5];
int[] sum = new int[5];
int total = 0;
//Get the info
for(int i = 0; i < b.length; i++ )
{
System.out.println("Enter data for Column " + (i+1));
for (int j = 0; j < b[i].length; j++ )
{
sum[i] += b[i][j] = getInt();
}
total += sum[i];
}
//Print the info
for(int i = 0; i < b.length; i++ )
{
for (int j = 0; j < b[i].length; j++ )
{
System.out.print(b[j][i] + "\t");
}
System.out.println();
}
//Print the sums
for(int i = 0; i < sum.length; i++){
System.out.print(sum[i] + "\t");
}
System.out.println("Total: " + total);
}
private int getInt()
{
int num;
String inStr = null;
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter integer data: ");
inStr = in.readLine();
}
catch(IOException ioe)
{
System.out.println(ioe);
}
num = Integer.parseInt(inStr);
return num;
}
}
[ January 08, 2004: Message edited by: David Hunt ]
18 years ago
Hi,
I am working on a program question from a tutorial website and so have done the following(below) but would like to make some alterations to meet the specifications better. Currently it prints a grid (matrix) and shows the sum of the columns at the bottom. The first change I would like to make is to ask the user to enter the number of columns and rows e.g. if they entered 10 - ten columns would be printed.
The second change I would like to make is to get the program to generate the numbers randomly instead of asking the user to input them. I think you have to use the =rand() to do this but I am struglling to work the rest out.
Could somebody implement the changes for me in the code or show me how to do it.
Thanks
---------------------------------------------------------------------------
import java.io.*;
class PrintMatrix
{
public static void main(String[ ] args)
{
PrintMatrix theApp = new PrintMatrix();
theApp.run();
}

private void run()
{
int[][] b = new int[5][5];
int[] sum = new int[5];
int total = 0;
//Get the info
for(int i = 0; i < b.length; i++ )
{
System.out.println("Enter data for Column " + (i+1));
for (int j = 0; j < b[i].length; j++ )
{
sum[i] += b[i][j] = getInt();
}
total += sum[i];
}
//Print the info
for(int i = 0; i < b.length; i++ )
{
for (int j = 0; j < b[i].length; j++ )
{
System.out.print(b[j][i] + "\t");
}
System.out.println();
}
//Print the sums
for(int i = 0; i < sum.length; i++){
System.out.print(sum[i] + "\t");
}
System.out.println("Total: " + total);
}

private int getInt()
{
int num;
String inStr = null;

try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter integer data: ");
inStr = in.readLine();
}
catch(IOException ioe)
{
System.out.println(ioe);
}
num = Integer.parseInt(inStr);

return num;
}
}
18 years ago
Ok I have done the following code, it asks the user for an integer then when it gets to 5(no of columns) it prints the a message with the total for that column(eg " Sum for column 4 = 23"). I would like to change it so it outputs the results at the end only and not after each column is entered. So could someone show me how this would be done as I cannot work out how to convert it. ie so after the user has entered each number when prompted it prints to screen a grid like below with the sum of each column underneath:
3 2 2 4 8
1 4 2 3 7
2 4 7 2 6
2 5 1 7 9
1 2 8 3 4
9 17 20 19 34
---------------------------------------------------------------------------
import java.io.*;
public class Matrix
{
public static void main(String[ ] args)
{
Matrix theApp = new Matrix();
theApp.run();
}
private void run()
{
int[][] b = new int[5][5];
for(int i = 0; i < b.length; i++ )
{
int sum = 0;
for (int j = 0; j < b[i].length; j++ )
{
sum += b[i][j] = getInt();
}
System.out.println("Sum for column " + i + " = " + sum );
}
}
private int getInt()
{
int num;
String inStr = null;

try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter integer data: ");
inStr = in.readLine();
}
catch(IOException ioe)
{
System.out.println(ioe);
}
num = Integer.parseInt(inStr);
return num;
}
}
---------------------------------------------------------------------------
18 years ago
Thanks a lot for your help. I'm sure I will be back with more questions once I have got something going
18 years ago
I am working on a question from a Java tutorial website(as I am trying to learn Java myself) could someone give me help on the following:
Whats Required:
Sequential program that receives as input a single Y x Z dimensional matrix (A) with a large amount of unsorted integer numbers(Created randomly).
The program then has to produce an N-dimensional array B containing the sum of the numbers in each A column(for example Bi = Ai1 + Ai2 + etc + AiN
(i = 1 .....M)
so the output I think would be as follows from what I understand from the question:
If the user entered 5,5:
3 2 2 4 8
1 4 2 3 7
2 4 7 2 6
2 5 1 7 9
1 2 8 3 4
9 17 20 19 34 << Columns added together
The only code I have came up with so far is(which as you can probably see is just the skeleton of the code):
import java.io.*;
public class Matrix
{
public static void main(String[ ] args)
{
Matrix theApp = new Matrix();
theApp.run();
}
private void run()
{
// Code to generate a number of random numbers (depending on user input)
// Adding the columns together and printing to screen grid
}
Could someone help me implement the missing code please.
Thanks for any help.
18 years ago
Has anyone got any idea because I am still stuck
18 years ago
Could someone implement the above in some java code for me please?
As I have two more similar questions to try out anyway so it would be great for someone to get me started.
Thanks a lot
18 years ago
I haven't got much worth posting so far. I am stuck I just can't get my head around it even though it sounds simple. I'll try and get it started and post some later but it would be much appreciated if you or someone else could get me started or put as much code as possible.
Thanks
18 years ago
Hi,
I have a question on a mock exam paper that i need to know the answer so I can learn it fo an exam I am doing in a few weeks.
This is it in a shorter format below; for the actual exam I will only need to put in bare bits of code not the whole thing but if possible could someone implement it in as much code as possible so it will make me understand it better.
Whats Required:
Sequential program that receives as input a single Y x Z dimensional matrix (A) with a large amount of unsorted integer numbers.
The program then has to produce an N-dimensional array B containing the sum of the numbers in each A column(for exmaple Bi = Ai1 + Ai2 + etc + AiN
(i = 1 .....M)

Thanks for any help.
[ December 16, 2003: Message edited by: David Hunt ]
18 years ago
I have now SOLVED the problem. It was do with having to typing the whole path /bin etc to sho windows where the javac.exe was(I found it on the java.sun website)
So sorry for taking up your time, all your help was much appreciated any way. No doubt I will be back with more problems soon.
Thanks
18 years ago
The first step when I try to compile the HelloWorldApp.java file when I type the command:
javac HelloWorldApp.java
it just gives the following error 'javac' is not recognized as an internal or external command, operable program or batch file
When I try:
javaw HelloWorldApp.java
it says: Could not find the main class. Program will exit (in a pop up)
Any ideas what I am doing wrong?
Thanks again
18 years ago