Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2: (a) In computer graphics, pixels are little dots that make up the image. We will define a pixel with two elements: 1) level

image text in transcribed

Question 2: (a) In computer graphics, pixels are little dots that make up the image. We will define a pixel with two elements: 1) level of brightness which is an integer between 0 and 255. 2) a color which might be either red, blue, or green. Write a class in java with the name Pixel as follows: 1. Define the attributes of the class to be private. Use the default values: 0 for the brightness and "red" for the color. 2. Define the default constructor 3. Define getters and setters for the private attributes. 4. Define the method incBrightness as follows. The method should increment the brightness level by the parameter amount. The parameter amount can be negative, in that case the brightness should be decreased. public void incBrightness int amount) 5. Override the toString method of the class such that it returns the following. Brightness: 433, Color: red (b) Write the tester class, Tester, in which you define the main method such that you do the following 1. Create two pixels with the following values. Brightness Color 100 Red 244 Green P2 2. Increase the brightness of pixel p2 by 100 3. Change the color of pixel pi to Blue. 4. Print the sum of brightness of both p1 and p2 5. Decrement the brightness of p1 by 50

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

Students also viewed these Databases questions