Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question for context picture class import java.awt.*; import java.awt.font.*; import java.awt.geom.*; import java.awt.image.BufferedImage; import java.text.*; import java.util.*; import java.util.List; public class Picture extends SimplePicture {

Question

image text in transcribed

for context picture class

import java.awt.*; import java.awt.font.*; import java.awt.geom.*; import java.awt.image.BufferedImage; import java.text.*; import java.util.*; import java.util.List; public class Picture extends SimplePicture { ///////////////////// constructors ////////////////////////////////// private final int LOW_FILTER = 4; private final int HIGH_FILTER = 64; /** * Constructor that takes no arguments */ public Picture () { /* not needed but use it to show students the implicit call to super() * child constructors always call a parent constructor */ super(); } /** * Constructor that takes a file name and creates the picture * @param fileName the name of the file to create the picture from */ public Picture(String fileName) { // let the parent class handle this fileName super(fileName); } /** * Constructor that takes the width and height * @param height the height of the desired picture * @param width the width of the desired picture */ public Picture(int height, int width) { // let the parent class handle this width and height super(width,height); } /** * Constructor that takes a picture and creates a * copy of that picture * @param copyPicture the picture to copy */ public Picture(Picture copyPicture) { // let the parent class do the copy super(copyPicture); } /** * Constructor that takes a buffered image * @param image the buffered image to use */ public Picture(BufferedImage image) { super(image); } ////////////////////// methods /////////////////////////////////////// /** * Method to return a string with information about this picture. * @return a string with information about the picture such as fileName, * height and width. */ public String toString() { String output = "Picture, filename " + getFileName() + " height " + getHeight() + " width " + getWidth(); return output; } /** Method to set the blue to 0 */ public void zeroBlue() { Pixel[][] pixels = this.getPixels2D(); for (Pixel[] rowArray : pixels) { for (Pixel pixelObj : rowArray) { pixelObj.setBlue(0); } } } /** Method that mirrors the picture around a * vertical mirror in the center of the picture * from left to right */ public void mirrorVertical() { Pixel[][] pixels = this.getPixels2D(); Pixel leftPixel = null; Pixel rightPixel = null; int width = pixels[0].length; for (int row = 0; row edgeDist) leftPixel.setColor(Color.BLACK); else leftPixel.setColor(Color.WHITE); } } } /* Main method for testing - each class in Java can have a main * method */ public static void main(String[] args) { Picture beach = new Picture("../images/beach.jpg"); beach.explore(); } }

8. Write the static method canHide that takes two pictures (source and secret) and checks picture sizes to make sure you can hide the secret in source. For now, this method should check if the two images are the same size, returning true if the two pictures have the same height and width, and false otherwise. This method will be modified in the following activity. Add code to main to test this method. * /** Determines whether secret can be hidden in source, which is * true if source and secret are the same dimensions. @param source is not null @param secret is not null @return true if secret can be hidden in source, false otherwise. * * public static boolean canHide (Picture source, Picture secret) 8. Write the static method canHide that takes two pictures (source and secret) and checks picture sizes to make sure you can hide the secret in source. For now, this method should check if the two images are the same size, returning true if the two pictures have the same height and width, and false otherwise. This method will be modified in the following activity. Add code to main to test this method. * /** Determines whether secret can be hidden in source, which is * true if source and secret are the same dimensions. @param source is not null @param secret is not null @return true if secret can be hidden in source, false otherwise. * * public static boolean canHide (Picture source, Picture secret)

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

2. Outline the functions of nonverbal communication

Answered: 1 week ago

Question

3. Is there opportunity to improve current circumstances? How so?

Answered: 1 week ago