<< Chapter < Page Chapter >> Page >
Listing 1 - Write the Java application described below.

/*File Prob01 Copyright 2012 R.G.Baldwin

Write a program named Prob01 that uses the class definition shown below and Ericson's media libraryalong with the image file named Prob01.jpg to produce the graphic output image shown in Figure 1 below.

Click Prob01.java to download a Java source file containing the solutionto this program.

In addition to the output image, your program must display your name and the otherthree lines of text shown below on the command-line screen:

Display your name here. A 300 by 274 world with 2 turtles in it.joe turtle at 256, 131 heading 45.0. sue turtle at 50, 37 heading 0.0.*********************************************************/ public class Prob01{//DO NOT MODIFY THE CODE IN THIS CLASS DEFINITION. public static void main(String[]args){ Prob01Runner obj = new Prob01Runner();obj.run(); System.out.println(obj.getMars());System.out.println(obj.getJoe()); System.out.println(obj.getSue());}//end main }//end class Prob01nd program specifications.

Figure 1 - Required output image for Prob01.

Missing image

Program 2

Discussion

The following is a non-exhaustive list of concepts that you need to understand along with knowledge and skills that youneed to possess in order to successfully write this program and/or understand the given solution in Prob02.java . Some of these items are general in nature and some are specific to the use of Ericson's multimedialibrary. I won't repeat the items listed under Program 1 above. Instead, I will concentrate on new concepts, knowledge, and skills not included in the above list.

  • How to design and implement an algorithm that will transform Prob02.jpg into the image shown in Figure 2 .
  • How to declare and initialize instance variables in a single statement.
  • How to instantiate a new object of Ericson's Picture class encapsulating the contents of a local image file.
  • How to call methods on the new Picture object for a variety of purposes.
  • How to declare a reference variable capable of storing a reference to a one-dimensional array object.
  • How to populate a one-dimensional array object of type Pixel[] with references to all of the Pixel objects encapsulated in a Picture object.
  • How to use a l oop structure to individually access the reference to each Pixel object in the array object.
  • How to use a reference to a Pixel object to modify the red, green, and blue color values belonging to the pixel that is represented by the Pixel object.
  • How use a pair of PictureExplorer objects to design and implement an algorithm that will transform the original image into the required output image shown in Figure 2 .
  • How to display your modified Picture object in an object of Ericson's PictureExplorer class.
  • How to confirm the validity of your algorithm by numerically comparing the color values in your output with the color values produced by compiling and running the program solution given below.
Listing 2 - Write the Java application described below.

/*File Prob02 Copyright 2012 R.G.Baldwin

Write a program named Prob02 that uses the class definition shown below and Ericson's media libraryalong with the image file named Prob02.jpg to produce the graphic output image shown in Figure 2 below.

Click Prob02.java to download a Java source file containing the solution to this program.

In addition to the output image, your program must display your name and the other text shownbelow on the command-line screen:

Display your name here. Picture, filename Prob02.jpg height 274 width 365*********************************************************/ public class Prob02{//DO NOT MODIFY THE CODE IN THIS CLASS DEFINITION. public static void main(String[]args){ Prob02Runner obj = new Prob02Runner();obj.run(); System.out.println(obj.getPicture());}//end main }//end class Prob02//End program specifications.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?

Ask