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

Say you're creating a sword, you could create an if statement, which checks array at the given random number, then checks the two array strings behind to see if the position is empty. If it is, then it sets all of the three array string values to 1.666, because that's what each is worth.

If any of the other squares aren't free, it should then check the two squares in front, then the two squares up and the two squares down, and if none of them are free it generates a new random.
vonhelmet said:
Just do it with a 2 dimensional array of 7 by 8. Much easier to create, easier to alter and easier to reference.
Good point.
 
Last edited:
jcb33 said:
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...
Fair enough.
 
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
 
jcb33 said:
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
I'd be extremely suprised if you hadn't. :\
 
jcb33 said:
An Integer
gdgd

Now you see in your op, you have System.out.println(" ------- -------");
well essentially you're printing a string, " ------- -------" to the console ;).

so if you said

String bob = " ------- -------"

then do System.out.println(bob)

you get " ------- -------" in the console.
 
Phnom_Penh said:
gdgd

Now you see in your op, you have System.out.println(" ------- -------");
well essentially you're printing a string, " ------- -------" to the console ;).

so if you said

String bob = " ------- -------"

then do System.out.println(bob)

you get " ------- -------" in the console.
Im still not following how that lets me randomly generate whole treasures on the grid while assigning them the correct value that can be used to add up the score at the end :confused: :( :eek:
 
Phnom_Penh said:
Strings are like the text equivalent of ints, you know what ints are right? :p

One thing to note is they aren't primitive types like ints, they're an array of chars so you have to treat them slightly differently when doing things like comparing them, e.g:

x == 1 would check if an int x is equal to 1, whereas with a String you'd have to do text.equals("text")

(also note the capital on String compared to primitive types such as int, char etc.)
 
jcb33 said:

heh, my final year project supervisor (and one of my lecturers) wrote BlueJ, and that OO book thing to go with it. personally not a huge fan of it because it seems like people end up needing to be weened off it, as they don't have any idea how to do anything outside of BlueJ.
 
One 2D Array.

Have a method called toString() which will print out a string representation of the array. It would consist of two nested loops going through the array and making one long string.

I wrote a small connect4 game in a lab. Remind me and I'll give you a few pointers.
 
Last edited:
Im currently trying to scan grid 2 for any number over 0, and each time it finds a number over 0 to add one to the "Uncovered" score but Im not doing very well

This:


Makes it so no matter how much is uncovered it says only 1 Pieces has been

and this:


Makes it display that 56 pieces have been uncovered even if they havent...

This is slightly closer but still not working...


21300000

00000000

00000000

00010000

00000000

00000000

00000300

You unearthed 7 piece(s) of treasure
 
Last edited:
Zogger said:
heh, my final year project supervisor (and one of my lecturers) wrote BlueJ, and that OO book thing to go with it. personally not a huge fan of it because it seems like people end up needing to be weened off it, as they don't have any idea how to do anything outside of BlueJ.

Yeah thats what I found as well. You should have seen the blank looks when the lecturer asked how to compile/run from the command line. Everyone was so busy right clicking on objects in Blue-J they didn't realise you needed an entry point (main) Heh. When your learning you are much better off with a syntax highlighting text editor and java(c). Then switch to an proper IDE later on for larger projects. IntelliJ rocks hard :-)
 
crystaline said:
Please can I hire one of you as my java buddy :(
You could hire me... But We dont start getting taught OO Java untill the 22nd Jan..... :(

But Boo Yeah, Now All Im left to do is

1) Randomly Place 5 to 7 of the 10 avaliable treasures onto the map while keeping them in tact

2) Create a replay option

1 is going to be the hardest as im just not sure where to start, I know I need Math.random, and some if statements but im not sure how to go about it
 
Back
Top Bottom