• Post Reply Bookmark Topic Watch Topic
  • New Topic

i dont understand this assignment  RSS feed

 
Dan D'amico
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some void method in a class, that changes a RGB color by switching all of its elements in this pattern :
for example : the RGB value (0,1,2) will chage to (255,254,253) what they mean by that ?
and how can i do this without any parameters in the void() method.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can we have some context please, perhaps a link to the document that contains the statement?

Henry
 
Dan D'amico
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
Can we have some context please, perhaps a link to the document that contains the statement?

Henry


i cant because its in a book and i dont have a camera right now. but i will try to write it shortly.

i built a class for colors. with private variables instances and public methods.
i need that one of those methods will be a void() one.
this method needs to change one given RGB set (red,green,blue)
for example (0,1,2) and changes it to (255,254,253).
i did something like that :
public void someMethod(){
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
}
but , its that simple ? or its some kind of a mathamatical pattern .
 
Ashwin Rao
Ranch Hand
Posts: 89
C++ Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the colors that we see around us are a mixture of the three primary colors red,green and blue.
In computer graphics the colors are formed by mixing the three colors mentioned above.
The intensity of each color is measured a number between 0 (don't use this color at all) to 255 (use this color to its full intensity).
For example: color(red = 0,green = 0,blue = 255) (this is just pseudo code and will not work in java I'm just using it to make the concept clear) represents blue.
color(red = 255,green = 0,blue = 255) form the color purple and so on you can form different colors by varying the intensity of each color.
Hope I helped.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan D'amico wrote:but , its that simple ? or its some kind of a mathamatical pattern .

It certainly sounds like it might be that simple, and in that case it would probably be "inverting" or "complementing" the colour (not sure of the exact term).

However, without more information, it's very difficult to say. Why don't you copy out the exact description from the book?

For example: What's this method called?

Winston
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan D'amico wrote:and how can i do this without any parameters in the void() method.

Why do you think the method has no parameters?

void means it doesn't RETURN anything - but nothing in your rather sparse description implies you can't pass in a parameter.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!