bibiki 18 Posting Whiz

hey Pobunjenik, sta ima? Alright, I am not sure I understand exactly what it is you are having problems with, but I think I found another bug in your code. This method:

public Player addPlayer(String soldierName) {
    this.allPlayers = new ArrayList<>();
    Player P = new Player();
    P.setName(this.name + soldierName);
    allPlayers.add(P);
    return P;
}

initializes your allPlayers list everytime it is invoked. Therefore, at any time it only has one player - not more.

Pobunjenik commented: Evo ništa, vježbam kod malo. :D +2
bibiki 18 Posting Whiz

hey bguild,
no, build method is not a static one. I was just trying to indicate that it is inside Builder. Sorry for the confusion. thanks for your answer. My understanding is that you say that I use a Builder inner class so that I do not have to write setter methods in my User class, and thus make User immposible to change state? Correct? But then, is there any downside to returning User from its setter methods instead of void if I decide to use them (other than making User possible to change state)? My previous assumption was that I only use Builder pattern so that I make possible setter method chaining.

bibiki 18 Posting Whiz

hey jacksonbird03, please see the two topmost threads in this java forum for projects for java beginners and resources to start java, first and second threads correspondingly.

bibiki 18 Posting Whiz

Hey there, I have a question regarding the builder pattern that I need someone with more experience to clarify for me.

I have this User class that has an inner, public static Builder class that has the same fields as User as well as the corresponding setter methods. Now, the setter methods inside the Builder class return this (the builder instance), and after everything is set, the instance of the builder is passed to Builder.build(this) method that returns a User instance with the fields.

My question is that I can make User setter methods to return this (User object) and render the inner Builder class unnecessary. However, since it is there, I assume there might be some reason why it is so. Anybody any suggestion as to why is one way better than the other?

Thanks in advance.

bibiki 18 Posting Whiz

Hello everyone,
I am puzzled... when I run a JUnit test, there is no main method in the class and it still runs. Alo, a java/maven web app does not have a main anywhere. My assumption is that it is hidden somewhere on some class I somehow extend or something. Can someone please explain is it there, and it yes, how to find out where it is?
Thank you in advance

~s.o.s~ commented: Good question +14
bibiki 18 Posting Whiz

why are you adding l_list to jscrolpane, and then adding l_list to p, and then again adding the jscrollpane to p?

bibiki 18 Posting Whiz

I think you need to set jscrollpane's size first

bibiki 18 Posting Whiz

let me try:
let as say you want to multiply 5 with 6.
upon first invocation of the method, add 5 to the first input param (that is five), and subtract one from 6. do this as long as the second param is bigger than 1. this, I believe, would be your recursive method. next time I comment, I write code. But writing code is against the rules, so brace yourselves :P

P.S. upon first invocation of the method, add 5 to the first input param (that is five), and subtract one from 6, and add to this the invocation of the method with 5 remaining the same, and pass for the second parameter whatever you get from 6 - 1 (the second parameter subtracted)

bibiki 18 Posting Whiz

I have some ideas, too.

One,
create an app that solves sudoku puzzles. you give it a situation, and then it solves it. You can create a GUI to make challenging your app with a sudoku puzzle easier.

Two,
create an app that seeks, finds, and shows all ways of placing eight chess queens on a chess board with no two of them on the same row, column, or diagonal. Another way to look at the problem is: every row and every column have each exatcly one queen on them.

Three,
create an app that simulates motion of earth around sun, and moon around earth. The challenge here is determining the position of moon as earth moves.

Perhaps a little mathematically challenging, but I did built these when I was more of a beginner, and I believe the experience has helped me.

bibiki 18 Posting Whiz

one of the three constituents of the criteria in the following sql query results to no query (at least one):

$sql = ("SELECT  * FROM sc_users WHERE username = '$myusername' and password = '$mypassword' and isadmin = 1 ;");

either you have no user with username gatekeepr (which I believe is the case, it very likely is gatekeeper)... or one of the other two... check for gatekeeper.

P.S. You have gatekeepr spelled wrong.

bibiki 18 Posting Whiz

Hey Marais,
thank you for your idea. However, seems like we both learned something from Chris.

Thank you Chris. That is how I will be creating my database. That suits my needs better.

kind regards.

bibiki 18 Posting Whiz

harinath, he is looking for how to store a number with 10^6 digits, not 10^6 itself.

bibiki 18 Posting Whiz

for what? to do your home work? no one will help you. you ought to show some work and tell us where exactly it is you are having difficulties before anyone will help you. otherwise, you might get price offers for doing you homework.

bibiki 18 Posting Whiz

I might be wrong, but I think you should do your research on image recognition instead of pattern recognition, and you might find a solution easier that way. otherwise, I don't know anything about either recognition, just thought I'd give an idea.

bibiki 18 Posting Whiz

hey there,
I have this java 3D home assignment I need help with. I would greatly appreciate it if someone could direct me to a solution.

I need to build create a 3 D digital clock and add some key navigation to it. I managed to add the key navigation (I removed the code for key navigation to make for less code), but I can't seem to make the necessary animation going... the scene should change every second, or else it will be a frozen clock.

what I did is this:

I built two classes. One to build the clock, and another, behavior class, that I hoped would 'repaint' the scene. I know the classes are interacting, but I am getting a:

javax.media.j3d.RestrictedAccessException: Group: only BranchGroup nodes may be set

error when I try to reset the child (a 3d shape representing time) of the TransformGroup in my code. However, I get no error when I invoke the createSceneGraph() method through my behavior class, but the clock remains frozen.

here is my code:

import java.awt.*;
   import java.applet.*;
   import java.awt.event.*;
   import javax.media.j3d.*;
   import javax.vecmath.*;
   import com.sun.j3d.utils.universe.*;
   import com.sun.j3d.utils.geometry.*;
   import com.sun.j3d.utils.applet.MainFrame;
   import com.sun.j3d.utils.behaviors.keyboard.*;
   import java.util.*;

   public class Detyra3D extends Applet{
      Shape3D shape;
   	
   	
      public void init(){
         setLayout(new BorderLayout());
         Canvas3D canv = new Canvas3D(null);
         add(canv, BorderLayout.CENTER);
      	
         BranchGroup bg = createSceneGraph();
        
         SimpleUniverse su = new SimpleUniverse(canv);
         su.getViewingPlatform().setNominalViewingTransform();
         

         
        
            su.addBranchGraph(bg);
 
      
      
      	
      }
   	
      public BranchGroup createSceneGraph(){
         BranchGroup scene = new BranchGroup();
      	
      	
      	
      	
      	
         Transform3D tr = new Transform3D();
         tr.setScale(0.45);
         tr.setTranslation(new Vector3f(-0.9f, -0.2f, 0f));
      	
      	
      
      	
      	
         TransformGroup tg …
bibiki 18 Posting Whiz

give me an upvote then... two days trying to get one off of you :P

bibiki 18 Posting Whiz

see this part of the code in your Graphics code:

else if (ring1ColChoice != ring1ColAns || ring2ColAns != ring2ColChoice || ring3ColAns != ring2ColChoice){

the last comparison is wrong. I assume you want to have ring3ColChoice as the last part...

bibiki 18 Posting Whiz

alright, I'll add the following book:
this is the book we use at school. it is freely distributed.

sneaker commented: thx for adding a book to the thread +4
bibiki 18 Posting Whiz

yes there is. you can use StringTokenizer class, tokenize your string using an empty space as a token (' ' - this would be your token), and then in a while/for loop, you'd print out a new line every third iteration or so. perhaps there are other ways, but this would work as well... no arrays used. I assume, under the hood, an array is used, but you wouldn't have to go through it...

n3red commented: Tnx +1
bibiki 18 Posting Whiz

alright, your application is all right, except for two minor defects.

one, you only have your application reading time once, that's why it repaints the same time every time it repaints. you need to put your line 28 somewhere where it is run each time a repaint is needed. that is, inside your for loop. and, another problem is that your thread sleeps a second and a half, which basically means that every third second is not painted. hope this helps.

bibiki 18 Posting Whiz

perhaps you can add some boolean variable and an if statement that check for truth value of the variable and call the repaint method only inside the if statement, which means that repaint will be called only while the boolean variable evaluates to true. hope that helps.

bibiki 18 Posting Whiz

seems like there is some trim() method calling going on somewhere under the hood. there are ways to insert a new line inside a string like using "\n". there might be similar for inserting space. I know there is for inserting a tab. consider that instead of just adding an empty string like this " " to your strings. do let us know if that works!

bibiki 18 Posting Whiz

yes pooja.shinde. James' explanation is correct, but you can make your code more efficient as Kiparsky said. try as an exercise to make your program more efficient. if you make the program more efficient, you will be sure you understand the logic. try first finding the prime numbers between 1 and 50 by hand, using your algorithm, and youll see for sure what we mean.

bibiki 18 Posting Whiz

I am new to this forum, and out of desire to contribute, I want to let you know that the best way to ask help is providing some code you have written. otherwise, you won't get other people do it for you. I wrote the code for two people and I was advised not to do that anymore, so I dont do it. but, write some code, do your best, and Im sure you will get help. I know I did get some very valuable help here.

bibiki 18 Posting Whiz

@BestJewSinceOJ
I'm sorry. I shall refrain from solving other people's problems in the future. yuo are right, I did not help the person learn I helped him do the homework.