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

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:
 
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:
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
 
Currently im trying to get the game to replay... at the beginging of my code I have:


and near the end My replay code is:


I realy cannot see how to get it to loop back ground to the beginging though
 
Last edited:
Rossmac said:
your call to method play() must be followed by a semi-colon to make it a legal statement.

ie.

play();
Added ; But now I cant launch the program at all

Code:
 
Last edited:
Una said:
Best way to do is is to have a game loop.

while (!gameOver)
{
// Do some stuff
}

Then when its game over you just set gameOver to true and your program terminates.

and obviously your missing a semicolon on play();

:)
That could be usefull save the fact that i want the game to replay, not terminate if the user selects replay
 
Una said:
Yeah then you have a switch/if statement somelogic inside your loop.

Different methods to display different bits of text....

One method that restarts the game etc...

When you want to replay you just call your play method again.

I have no idea how I would go about that :/
 
Now there is just one thing left to do.... place my treasure randomly:

Must place no more than 5 to 7 of the 10 avaliable pieces at any one time

Must keep items in tact

This one is still a mystery to me, im guessing I need to use Math.Random somehow but ... urgh
 
Chrisss said:
He wants it spoonfed to him though.

;) To Be fair I have been editing my posts and updating to myself along the way, it is nice however to get help, and as for random numbers, yes I can generate them... hence why I got the computer to have random guesses for the user, what I dont know how to do is randomly place 3 cells in order without seperating them

Code:
}
 
Last edited:
5ingh said:
Hmm if this is coursework etc, I wouldn't be posting it on the internet, esp considering all(?) uni's have special software that searches the net for any matches with the work you hand in.
Would you actualy get in trouble for having the work you have done posted by you on the net?
 
Johanson said:
Well if asking for a bit of maths help is 'cheating ', this thread must be worth a jail sentence at least.
Your signature is perdy..... But less of the distractions, I would hardly class your thread as cheating and I need to figure a way to randomly place treasures :D
 
Chrisss said:
Well his university may have rules against showing code to other people. For instance, someone on your course may stumble accross this thread and steal your code.
Good point, dident think of that, Removed all my code and hope no one has coppied or im royaly.....
 
Im trying to get the treasure to place randomly using Math.Random but so far All I can manage is to cover the grid with Rings not just place one

Code:
                    {            {
                int x=(int)(Math.random()*7+1), y=(int)(Math.random()*8+1);
                         
               if(grid1[x][y] == 0)
               {             
            grid1[x][y] = ring;
        }
        else if(grid1[x][y]>0)
        {        
          grid1[x][y] = ring;
          }
          
                         
            if(grid1[x][y] == 0)
            {
                grid1[x][y] = ring;
            }
           
            if(grid1[x][y] == 0)
            {
            grid1[x][y] = sword;
            grid1[x][y] = sword;
            grid1[x][y] = sword;
        }
        
         else if(grid1[x][y]>0)
            {
            grid1[x][y] = sword;
            grid1[x][y] = sword;
            grid1[x][y] = sword;
        }
        
         if(grid1[x][y] == 0)
            {
            grid1[x][y] = sword;
            grid1[x][y] = sword;
            grid1[x][y] = sword;
        }
         else if(grid1[x][y]>0)
            {
            grid1[x][y] = sword;
            grid1[x][y] = sword;
            grid1[x][y] = sword;
        }
            
           if(grid1[x][y] == 0)
           {
            grid1[x][y] = statue;
        }
        else if(grid1[x][y]>0)
    {
            grid1[x][y] = statue;
        }
            if(grid1[x][y] == 0)
            {
            grid1[x][y] = chest;
            grid1[x][y] = chest;
            grid1[x][y] = chest;
            grid1[x][y] = chest;
                
        }

Im trying to get it so it only places 7 of the 10 avaliable pieces at any one time, and so that it randomises their location each time
 
Last edited:
Plus-44 said:
Absolutely agree with you, there's a guy on my course who sponges coding from everyone and it does my nut in. I've learnt to keep my code to myself. He doesnt want to learn he just wants to get the answer straight away, I cant see the point in coming if your gonna do that.

+44
Ah but I want to learn, I just dident realise that you need to be 10 steps ahead of what your being taught so dident know how to do.. well much over helloworld. I have learnt a lot from doing this, and I havent been drip fed everything, I fully admit that I got a lot of help, but even so, anything I was given I refused to copy, I learnt how it worked, and why it worked, and then wrote up my own version and kept playing untill I got it working.

I do not plan on sponging off anyone for my course, nor have I in any of my other assignments, but with this I realy did need help.

And as soon as I get some free time Im going to get myself some Programing for dummies books and make sure I do a little each day untill I feel I am compitant.

I also found it quite fun, while very frustrating trying to solve my own problens for example with the if statement earlier I had a ; in the wrong place and it would not work and I was staring at thoes lines for hours but I wont forget how to do an if statement in a hurry and I was able to solve other problems thanks to this.

So While I do See where you are coming from, and I acknowlege I got to much help with this I would prefer you did not stereotype me as someone who is going to plagerise everyone elses work while I am at uni. I have worked hard to get here, gone through many problems that you will never know about but managed to come out the other end and pull myself up and into uni. I am going to get my degree because I am determined not to fail, I will learn as much as I can (Now I realised how much I actualy need to know :p ) and prety much thats all I have to say....

Now onto my next assignment.... *Wonders off into the distance singing*
 
Last edited:
Welshy said:
That's pretty much what ive said since the start of this thread....

Answers to any of the questions made by JCB in this thread could be answered by using a book, googling for tutorials, or actually turning up to lectures/tutorials?
I will also note I have not missed a single lecture, workshop or other since I started uni
 
Bes said:
Oh so you didn't realise University required you to be able to work independently and direct your own learning?

And I hope you don't mind me advising you that your spelling and grammar are appalling for someone who is aiming for a degree? I really hope you brush it up for your CV and covering letter, as no employer in their right mind would take you and your potentially ill-gotten degree on board with a CV riddled with spelling errors.

Now now, no need for sarcasm, I did realise that yes, but I did not realise how far ahead the assignment would be compared to what we have been taught.

Also I know my spelling is bad, but then again being dyslexic does not realy aid that. I make certain that anything important is done well, and I have been employed in the past without problems (Still am).

I would also comment that my degree will not be "Ill Gotten" but earned via the use of hard work which I intend to be putting in for the next 2 and a half years.

I would also like to ask you to stop commenting on this thread and find someone else to insult, but if you wish to continue I will simply ignore it.

Dons please remove this thread now, I think its about done.... *Dons flame retardent suit and walks off*
 
Chrisss said:
With code like this being written:

Code:
if(grid1[x][y] == 0)
            {
            grid1[x][y] = sword;
            grid1[x][y] = sword;
            grid1[x][y] = sword;
        }
        
         else if(grid1[x][y]>0)
            {
            grid1[x][y] = sword;
            grid1[x][y] = sword;
            grid1[x][y] = sword;
        }
        
         if(grid1[x][y] == 0)
            {
            grid1[x][y] = sword;
            grid1[x][y] = sword;
            grid1[x][y] = sword;
        }
         else if(grid1[x][y]>0)
            {
            grid1[x][y] = sword;
            grid1[x][y] = sword;
            grid1[x][y] = sword;
        }

...I wonder how many lectures you actually paid attention in.

That was actualy an experiment to try and get randomisation working, which I have managed to do using Math.random and lots of if statements!

Also a note we dont get taught to program in lectures, we get taught about programing, e.g we had 5 lectures on "The Watefall Theory" all of the lectures were almost identicle and most people on our course says the lecturer is useless, im inclined to agree

and hodders, I dont take that as an atack, infact your not even having a dig at me, unlike some of the above posts your not sayin "OH NOES your a plageriser fail uni fail uni you dont deserve to be there" like others, I apreciate your advice, and tbh im pleased with this assignment, even though I got a lot of help I got more of it working on my own than I thought possible..... again dons please remove this thread now!
 
We had to

Create Software Solution

Briefly Describe Black and White box testing

Generate White box data for a section of code
 
Back
Top Bottom