Programming-Slaent?
- Page 1 of 1
Was just wondering if there were any programmers here. Would be very helpful if anyone here knows Java, since I'm having a little trouble with my assignment.
If i get home and i'm sober and still awake i'll have a look at it more.
In theory, i'm a programmer.
In theory, i'm a programmer.
I can't read Dutch and the formatting is a mess, but your method of spreading the color is pretty suboptimal. What you should do is to use a list to keep track of the squares that you need to inspect.
Say you move from square A to square B, your logic should be something like this:
Change square B to color A
Add square B to the list.
While (list is not empty) {
Remove current entry from the list
If any of the adjacent squares is the same color as B, change it to color A, then add it to the list
}
You can use list, array or whatever data structure you like.
Say you move from square A to square B, your logic should be something like this:
Change square B to color A
Add square B to the list.
While (list is not empty) {
Remove current entry from the list
If any of the adjacent squares is the same color as B, change it to color A, then add it to the list
}
You can use list, array or whatever data structure you like.
Yeah, I know it's a mess. Not the best at doing things in a clean way, and only started "programming" half a year ago.
And hadn't thought of that. Thanks, I'll look into it.
Also, can anyone help me with the first question about reading a files?
And hadn't thought of that. Thanks, I'll look into it.
Also, can anyone help me with the first question about reading a files?
I don't know Java, but as far as relative paths go, look into how to read environment variables, specifically the user name variable if the file is going to end up somewhere where the path is like "C:\Users\UserName\...".
For the first question, might be worth uploading a sample of the text file, and explain what you want to do with it.
By OrtixYeah, I know it's a mess. Not the best at doing things in a clean way, and only started "programming" half a year ago.
And hadn't thought of that. Thanks, I'll look into it.
Also, can anyone help me with the first question about reading a files?
I actually played the game a short while ago. If you're trying to do everything the game does, it's a bit more complicated than that.
Some of the later stages you have to do multiple moves concurrently, so your algorithm will have to able to multitask and resolve several moves at the same time.
https://www.youtube.com/watch?v=7n4Npr46RTE
By linsivviBy OrtixYeah, I know it's a mess. Not the best at doing things in a clean way, and only started "programming" half a year ago.
And hadn't thought of that. Thanks, I'll look into it.
Also, can anyone help me with the first question about reading a files?
I actually played the game a short while ago. If you're trying to do everything the game does, it's a bit more complicated than that.
Some of the later stages you have to do multiple moves concurrently, so your algorithm will have to able to multitask and resolve several moves at the same time.
https://www.youtube.com/watch?v=7n4Npr46RTE
Nah, for now it's just the basic stuff (first 2 stages). I couldn't even complete those myself :lol
So, need some more java help, if any of you are willing to help.
I want to "change" the page when a JPanel is clicked on another page.
say
This however does not seem to work. (I can see the first window, but nothing happens when I click on the panel)What am I doing wrong?
I want to "change" the page when a JPanel is clicked on another page.
say
public class Frame extends JFrame{
private JPanel firstWindow
private JPanel secondWindow
Frame(){
setDefaultCloseOperation(WindowsConstants.EXIT_ON_CLOSE);
setVisible(true)
setSize(800,500)
firstWindow = new JPanel();
firstWindow.setLayoutManager(new BorderLayout());
JPanel clickablePannel = new JPanel();
clickablePannel.addMouseListerer(new MouseAdapter(){
@0verride
public void MouseClicked(MouseEvent e)
{Frame.this.goToSecondWindow();}
}
firstWindow.add(clickablePannel,BorderLayout.CENTER)
this.add(firstWindow)
}
private void goToSecondWindow () {
this.removeAll();
secondWindow = new JPanel();
this.add(secondWindow);
this.repaint();
}
}
This however does not seem to work. (I can see the first window, but nothing happens when I click on the panel)What am I doing wrong?