Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Eclipse, create a new project. Add a package imageloop, and a class pictures to that package. Method name: hideLetterA Parameter(s): A String. An empty

In Eclipse, create a new project. Add a package imageloop, and a class pictures to that package.

  1. Method name: hideLetterA Parameter(s): A String. An empty string is allowed. Return value: A String that has the same characters as the String parameter except every letter 'a' has been changed to an '*'. Example: hideLetterA("A rabbit has a carrot") would return "A r*bbit h*s * c*rrot". Note: The letter 'A' is not 'a'.
  2. Method name: hasMoreEvenThanOdd Parameter(s): A String containing only integer numbers separated by spaces. An empty string is allowed. Return value: A boolean value true if the number of even numbers in the String is greater than the number of odd numbers and false otherwise. Example: hasMoreEvenThanOdd("1 3 4 6 -8") would return true. Note: The % operator can be used to check if a number is evenly divisible by 2, which is what being even means. Second note: 0 is not a special case for being even or odd.
  3. Method name: makeTextTriangle Parameter(s): An int value that can be assumed to be greater than 0 and less than 20 (this is really just a constraint for formatting). Return value: A String value that makes a text triangle. The first line should have a single "*". Any following line, if needed, should have 1 more "*" than the line above it, until there are as many lines as the parameter value. Example: makeTextTriangle(4) would return * ** *** **** with each line ending in a new line. For the following methods, please review the slides and examples from lecture 8. In particular, follow the pattern of making a copy of an image and applying changes to that copy rather than to the Picture object sent as a parameter.
  4. Method name: makeGrey Parameter(s): A Picture object. This is the source image. Return value: A new Picture object. Each pixel in the returned Picture should have a color that is the grey scale equivalent of the corresponding pixel (the pixel with the same x and y coordinate) in the source image. In general, a grey scale color has different ways of being calculated - you must calculate it by averaging the red, green, and blue values from the pixel in the source image and then setting each of the red, green, and blue components of the pixel in the new image to this grey intensity. Example: A single pixel image with a color (100, 200, 50) would have a grey intensity of (100+200+50)/3 = 116 and the new image would be a single pixel with color (116, 116, 116). An example of what a result might look like is the following (please don't treat this as a reference image as I am unsure of what compression or changes might be applied by Canvas).
  5. Method name: makeNegative Parameter(s): A Picture object. This is the source image. Return value: A new Picture object with the colors changed to a photonegative style. Each pixel in the returned Picture should have a color that is a "negative" of the corresponding pixel (the pixel with the same x and y coordinate) in the source image. You must calculate this by taking each red, green, and blue value in the source and setting it to 255 - each value in the returned image. Example: A single pixel image with a color (100, 200, 50) would make a new image with a single pixel with color (155, 55, 205). An example of what a result might look like is the following (please don't treat this as a reference image as I am unsure of what compression or changes might be applied by Canvas).
  6. Method name: safeColor Parameter(s): A single int value representing one of a red, green, or blue value. Return value: An int that is the same as the parameter, except that it is 0 if the original value is less than zero and it is 255 if the original value is greater than 255. Example: If the parameter is 100, then the return value should be 100. If the parameter is 300, then the return value should be 255.
  7. Method name: makeBrighter Parameter(s): A Picture object. This is the source image. Return value: A new Picture object with the color values doubled. Each pixel in the returned Picture should have a color that has each red, green, and blue component twice that of the corresponding pixel (the pixel with the same x and y coordinate) in the source image. Unthinkingly applied, this doubling will yield color values outside the allowed 0-255 range, which crashes the program. Clamp each calculated red, green, and blue value to a safe range by applying the safeColor method written above to the colors you calculate. Example: A single pixel image with a color (100, 200, 50) would make a new image with a single pixel with color (200, 255, 100). An example of what a result might look like is the following (please don't treat this as a reference image as I am unsure of what compression or changes might be applied by Canvas).

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

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions