d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Anyone Good At "processing"?
12Next
Add Reply New Topic New Poll
Member
Posts: 10,083
Joined: Aug 19 2007
Gold: 0.00
Oct 8 2014 08:15am
I didn't really know where to post this, but seeing as processing seems java inspired I just posted it here.

I need some help with an exercise that I don't really know how to do, and I would really appreciate if someone could help me =)

PM me if you're good at processing or think you can help me :)
Retired Moderator
Posts: 18,570
Joined: Feb 27 2004
Gold: 11,858.00
Trader: Trusted
Oct 8 2014 08:19am
Post your questions, code, and/or instructions here and you will receive a faster response as well as reach a wider audience.
Member
Posts: 10,083
Joined: Aug 19 2007
Gold: 0.00
Oct 8 2014 08:48am
Quote (Blind[zF] @ Oct 8 2014 02:19pm)
Post your questions, code, and/or instructions here and you will receive a faster response as well as reach a wider audience.


Alright

So this is what the exercise is:




This is how far I am with exercise a)
http://pastebin.com/Jb0BBjQu


I know the function is wrong, but my problem is that I don't really know how to do the "button" as argument, maybe I should have made all the 3 buttons into one 2d array instead.
If anyone could point me in the right direction or show me how it's done with explanaton, I would be very very grateful!
Retired Moderator
Posts: 18,570
Joined: Feb 27 2004
Gold: 11,858.00
Trader: Trusted
Oct 8 2014 09:05am
You need to pass in your button array into the method drawButton.

My syntax may be off as I'm not to familiar with JAVA but essentially this is what you need to do for the first part.

Try to get that working first.

Code
int[] button1;
int[] button2;
int[] button3;

void setup(){
size(800,800);

int[] button1 = {250,250,200,200,150,160,170}; // x, y, width, height, red, green, blue

drawButton(button1);
}


void drawButton(int[] buttonArray) {
fill(buttonArray[4],buttonArray[5],buttonArray[6]);
rect(buttonArray[0],buttonArray[1],buttonArray[2],buttonArray[3]);
}


* Edit - Changed the drawButton function as I didn't update your array variables in there. Currently at work so a bit busy and not focused.

This post was edited by Blind[zF] on Oct 8 2014 10:09am
Member
Posts: 10,083
Joined: Aug 19 2007
Gold: 0.00
Oct 8 2014 09:09am
Quote (Blind[zF] @ Oct 8 2014 03:05pm)
You need to pass in your button array into the method drawButton.

My syntax may be off as I'm not to familiar with JAVA but essentially this is what you need to do for the first part.

Try to get that working first.

Code
int[] button1;
int[] button2;
int[] button3;

void setup(){
size(800,800);

button1 = {250,250,200,200,150,160,170}; // x, y, width, height, red, green, blue

drawButton(button1);
}


void drawButton(int[] buttonArray) {
fill(button1[4],button1[5],button1[6]);
rect(button1[0],button1[1],button1[2],button1[3]);
}



It just says "unexpected token: {"

I don't see anything wrong syntax :/




This post was edited by Polsenols on Oct 8 2014 09:31am
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Oct 8 2014 04:45pm
Quote (Polsenols @ Oct 8 2014 11:09am)
It just says "unexpected token: {"

I don't see anything wrong syntax :/


http://i.gyazo.com/44d5f419356a41d9d8b59f20c5b7aed9.png


you can't initialize it this way. it has to be on the same line it's declared on. either move it up to where you declare it or use a different syntax.
Member
Posts: 23,444
Joined: Jun 30 2009
Gold: 167.53
Oct 15 2014 08:38am
Quote (Blind[zF] @ Oct 8 2014 11:05am)
You need to pass in your button array into the method drawButton.

My syntax may be off as I'm not to familiar with JAVA but essentially this is what you need to do for the first part.

Try to get that working first.

Code
int[] button1;
int[] button2;
int[] button3;

void setup(){
size(800,800);

int[] button1 = {250,250,200,200,150,160,170}; // x, y, width, height, red, green, blue

drawButton(button1);
}


void drawButton(int[] buttonArray) {
fill(buttonArray[4],buttonArray[5],buttonArray[6]);
rect(buttonArray[0],buttonArray[1],buttonArray[2],buttonArray[3]);
}


* Edit - Changed the drawButton function as I didn't update your array variables in there. Currently at work so a bit busy and not focused.


I know I shouldn't be giving Mods advice but next time try to give him the answer in a different language. I was gonna give him the answer in Python so that he had to at least read the code and understand what is going on so that he would be able to translate it back into java. Too many people out there getting a computer science degree with minimal coding abilities.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Oct 15 2014 08:45am
You're replying to a week old post. Among the people scrapping by with no understanding of the material, there are also those with a self sense of superiority who lack basic observational skills.

The thing is, those with a CS degree who can't code get weeded out in the tech screening of a job interview. Self-entitlement is harder to flush out.
Member
Posts: 23,444
Joined: Jun 30 2009
Gold: 167.53
Oct 15 2014 09:26am
Quote (Minkomonster @ Oct 15 2014 10:45am)
You're replying to a week old post. Among the people scrapping by with no understanding of the material, there are also those with a self sense of superiority who lack basic observational skills.

The thing is, those with a CS degree who can't code get weeded out in the tech screening of a job interview. Self-entitlement is harder to flush out.


Contrary to how my post sounds, I was not trying to say that I was better at the material than anyone else. I was only giving a suggestion. Just woke up and replied so I was groggy. Sorry my "observational skills" were lacking at the time. I'll try to tone down my ego as per your request.

This post was edited by umeshieee on Oct 15 2014 09:42am
Retired Moderator
Posts: 18,570
Joined: Feb 27 2004
Gold: 11,858.00
Trader: Trusted
Oct 15 2014 09:32am
Quote (umeshieee @ Oct 15 2014 09:38am)
I know I shouldn't be giving Mods advice but next time try to give him the answer in a different language. I was gonna give him the answer in Python so that he had to at least read the code and understand what is going on so that he would be able to translate it back into java. Too many people out there getting a computer science degree with minimal coding abilities.


Advice is always welcomed, granted that it is done in a constructive manner. This is a discussion forum after all.
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll