yay last min uni work part 2.... I need help

Soldato
Joined
11 Apr 2003
Posts
4,208
Location
Notts
Yes yes, I know your all going to have a go at me, and even when I give my reason you will tell me there is no excuse but all the same.....

I have to do a piece of programing that is done in bluej and uses simple java language (Not object orientated) to create a treasure hunt game. Now I have only untill thursday to get this done, tested and handed in, the reason I have not done it over Christmas (While I do admit I was kinda putting it off as well) Is that I actualy have no idea how to do it, I Know how to write a helloworld program but beyond that everything they told me about programing seems to make little sense (I realy wish I had chosen the other course my uni offers as programing + me = :( :( :( ) Anyway I have to follow the guidelines on the following:

http://s29.quicksharing.com/v/346349/Programing.pdf.html

and have it meet the criteria here:

http://s29.quicksharing.com/v/2691364/Programing_Refference_Grid.pdf.html

I was wondering if anyone could give me any tips on getting going with this, give me something good to read etc, I was planning on creating the 8x7 grids first however apart from going

System.out.println(" ------- -------");
System.out.println("| || |");
etc, I have no idea how to do this, it does say that a visible grid is not expected, however that still leaves the need for a base grid to actualy work with..... urgh thanks if anyone can/will help me however!
 
SiriusB said:
I can't tell you how to do this, that would be cheating, but for the grid you will want to look at 2-Dimensional Arrays. A clue to this is given in one of the PDFs, mentions the user entering coordinates [row, column] <-- screams 2D array.

If you are using BlueJ then I assume you have the book it came with, everything you need should be in that book. I should know, I used it for two years :p

SiriusB
Nope no book, its a free download the uni linked us to... But thanks Im sure there must be something I can find now I know what to actualy search for!
 
Psyk said:
If you're using Java, how come you can't do object oriented programming :confused:
Ah god knows my uni, They are doing programing that uses no O_o this semester than teaching o_O next unit..... then onto C++ In year 2 :confused:
 
Thanks to the above help, I have managed to create a grid (Although its not a visible one as such) im now trying to work out a few things however

1) How do I transfer data from the grid with the treasure, to the grid the user can see, e.g when they uncover a ring, in 1,1 then the blank data on the second grid becomes "Ring"

2) How I make the computer place the treasure randomly

3) How I make the computer select 5 random coordinates

4) How I assign a score to each item/part of item of treasure

5) How I make an ending, where if the player says 1 to continue the program loops back to the beginging otherwise the program exits....

I got a lot done today so far but still so far from finished and have no clue how to be finished :(
 
vonhelmet said:
I predict you will soon be back asking how to get input from the user.

Nah, I actualy have that one covered by using TextIO! Hoorah, I just need to make the computer generate random things, get the second grid to display what is uncovered and add the score up at the end + offer chance to replay... Will try the above so thanks for the help, just hope i can get there!
 
Sigh, I dont know how im so bad at Java.... Been sitting here an hour and still can't work out how to make grid2 show the data from grid one in the grid sections that user picks.... Sigh
 
Welshy said:
Lets say the user inputs an x and y value, we'll call these inputX and inputY. grid1 is the grid you've stored the treasure in, and grid2 is the grid being displayed. Dont forget to take one away from the values the user inputs as arrays start at 0.
Code:
if (grid1[inputX - 1][inputY - 1] != '')
{
    grid2[inputX - 1][inputY - 1] = grid1[inputX - 1][inputY - 1];
}
else
    grid2[inputX - 1][inputY - 1] = '';
As simple as that really, if im following what you want to do correctly.
 
Last edited:
Rossmac said:
JCB - my friends dad designed that logo, random fact.

Anyways, if you want to send me your code so far? I could have a look and help you out a bit if needed.

Send it to [email protected]
I have added you on msn, if you can get online? Would realy apreciate the help!
 
With a lot (Although he says not) Of help from Rossmac I now have a program that is somewhat functional that is the user can put in a guess and it will be displayed if they hit treasure or not!

Now I have to:

Make the treasure be placed randomly, and looking at random numbers im realy not sure how to do this, especialy not sure how to make sure specific treasure is placed randomly and correctly, e.g a sword that is 3 grid places large needs to be placed in a row, not broken into 3 different bits..... any help there would be great!

Need to make the computer give the user 5 random guesses of its own no idea how again as of the above problems

Need to assign values to the items of treasure and give a score at the end, im currently working on setting up a score table but it just spams it before the user inputs a guess meaning its not doing its job.... not sure how to fix that

and I need to create a replay option
 
Im currently trying to create a loop that goes like this

System.out.print("If you would like to play again press 1, if not press 0);

Then If the user presses 0 I want the game to say "Thank You For Playing"
and if they press 1 I want the game to loop back to the start

So Far I have


But for some reason Y no matter what you enter it still says Thank You For Playing! and ends, and I am unsure how to loop it back to the beginging of the game...
 
Last edited:
Psyk said:
You do realise it's common for comp sci departments to have plagiarism detectors that search the net? And simply renaming variables won't be enough to throw it off.
Hence why im not copying stuff, im looking at it as an example, searching for more on it, learning what it does and why it does it and then rewriting it in my own format...
 
Phnom_Penh said:
You don't need it in it's own class, I'd just put it in the game's class in it's own method, and then call the method from the main class after they'd played the game.

public void playagain()
{
Scanner sc = new Scanner(System.in);
System.out.println("Would you like to play again? Please enter Y for yes or N For no");
public String replay = "Y";

While(String replay.equals("Y")
{
replay = sc.nextLine().toUpperCase();
If(replay.!equals("Y") & replay.!equals("N"))
{
System.err.println("You're an Eegit");
System.exit(-1);
}
Else If(replay.equals("Y")
{
game.game();
}
Else
{
System.exit(1);
}
}

Would there be any way to do it in the line of thought I was having? Realy want to keep it in the relms of what we have been taught if possible... or at least simple as we were not taught random numbers hence my inability to randomly place the treasure!
 
Phnom_Penh said:
You'd be expected to look stuff up. Random numbers is easy.
Well I have the computer taking 5 random guesses for the user... but I need to get the treasure to place randomly on the grid each game, But I also need to keep the treasure in tack, e.g a sword is 3 cells long, and i need to keep it 3 cells long so placing it randomly becomes confusing...
 
vonhelmet said:
You're making the array too complicated. There's no need to make one 56 length array. Can you imagine the work in parsing that to generate the output?

Just do it with a 2 dimensional array of 7 by 8. Much easier to create, easier to alter and easier to reference.


I thought I had created 2, 2d arrays.... urgh this is so confusing heh
 
Last edited:
Phnom_Penh said:
I'd create an array of strings. I'd then convert the strings to ints using the parseInt command.
I wish I knew what that was all about, but tbh I just have no clue how to do what you said at all we havent even heard of strings in our course as far as I know yet
 
Back
Top Bottom