Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


COM6471 – Foundations of object-oriented programming

Assignment 2


This is the second assignment for COM6471 Foundations of Object Oriented Programming, and it is worth 30% of your final module mark. This assignment and is intended to assess your knowledge and understanding of the use of loops and arrays in Java.


Programming task

You have been provided with three files, which contain information about an image. The files contain the red, green, and blue components of the colour of each pixel in the image. For example, the file UoSsecret_red.txt contains the intensity of red in each pixel, stored as an integer that has a value between 0 and 255. The size of the image is 420 rows x 841 columns, and these values are fixed.

A secret message has been hidden in the image using a technique called steganography (see https://en.wikipedia.org/wiki/Steganography). The secret message is a text string with 65 characters. Each character is represented by its numeric value, and has been hidden in a random location in the image. The co-ordinates of each character have been stored in the first two columns of the blue component of the image (i.e. the data stored in UoSsecret_blue.txt); the first column contains the row co-ordinate, and the second column contains the column co-ordinate.

The aim of this assignment is to write a Java program that (i) displays the image in a window as shown, (ii) decodes the secret message, and displays it as a String in the terminal or command window, and (iii) displays the image again, showing the location of the modified pixels.


Detailed information and requirements

Format of the text files

Each text file has been prepared using code that writes out the red, green, and blue intensities of the image in a raster format, so the first 841 integers in each file corresponds to the first row of pixel intensities, and so on. So, each file contains 420 x 841 = 353220 integers. You should think carefully about how you could use loops to read the data in from each file, and how the data are to be stored in a two-dimensional array.


Requirements for your program

● Your program should be a class called SecretMessage, and should be stored in a file called SecretMessage.java.

● Your program must use EasyReader to read in the data, and must use EasyGraphics to display the output. You should examine EasyGraphics.java to identify suitable methods to use for display of the images.

● You should not include any path information when your program uses EasyReader to open the input files. You can assume that these are stored in the same folder as the program code.

● Your program should display the secret message in the command widow or terminal.

● Your program should display the images in single windows as shown below; the original image is shown on the left, and the image on the right shows the location of the modified pixels. Each modified pixel should be highlighted with a red circle 10 pixels in diameter.


How to proceed

As with Assignment 1, you should aim to develop your code incrementally, checking that it compiles and runs at each stage. I recommend that you follow these steps.

1. Write some code to read in the data from one file only. Examine the data using loops and System.out.println(), and make sure that you understand how the data are arranged.

2. Try displaying one colour component of the image in an EasyGraphics window. Think carefully about what sort of loop(s) to use. Check that your idea works.

3. Adapt your code to read in all three colour components. Think about how you could do this efficiently, i.e. without repeated lines of code.

4. Identify the co-ordinate information in the first two columns of the blue component data stored in UoSsecret_blue.txt. Identify the numbers stored at these co-ordinates and how these can be turned into characters and then stored in a String. Display the String on the command window or terminal.

5. Write code to display the image again, highlighting the locations of each character.


Submission

Your code should be submitted as a single java file called “SecretMessage.java” and uploaded to Blackboard using the upload tool before the deadline. You do not need to submit the sheffield classes, or the input files (e.g. UoSsecret_blue.txt).


Assessment

Your code will be assessed for functionality and style. A mark of zero will be awarded for programs that do not compile; it is therefore important that you check that your code compiles before you submit it.

The marking scheme will be as follows:

25-30 marks – Classes, methods, and instance variables used extensively and sensibly, with constants used where appropriate. Clear code layout. Useful, descriptive comments. All the required functionality implemented, with some additional functionality or other evidence of flair.

20-25 marks – Classes, methods, and instance variables used sensibly, with constants used where appropriate. Clear code. Some meaningful comments. All the described functionality implemented.

15-20 marks – Classes, methods, and instance variables used. Readable code, if not perfectly organised or presented. Most of the functionality is present

10-15 marks – Confusing but basically functional code. Some functionality present.

0-10 marks – Few recognisable components of the required functionality present. Some meaningless code fragments.

You should also bear in mind the following points:

● The main class will have a header comment, typically specifying the program name, the author, and the date.

● The code is indented consistently throughout, so that the code in the main method is easily identified.

● Variable names are chosen sensibly, so that the code is self documenting.

● There are sufficient lines of code to meet the requirements, and no extra or unnecessary code. For this assignment, there is no need to specify additional classes or methods, except for the sheffield classes.