Write a program to read in data points into a grid.
The data points should be bytes (characters).
Generate a 1-byte code for each element in the grid that indicates whether each of the 8 neighbors of any given element in the grid is equal to the current element. Your output will be a grid of values that has the same dimension as the original grid. Save the output to a file.
Create your own input data. Expect an example input file in binary form for the next version of this assignment.
Here’s an example simple input data file. You don’t have to use this method but it suggests a way if you can’t think of your own. The first line is the dimensions. Data follows.
6 26 abcdefghijklmnopqrstuvwxyz zabcdefghijklmnopqrstuvwxy yzabcdefghijklmnopqrstuvwx xyzabcdefghijklmnopqrstuvw yzabcdefghijklmnopqrstuvwx zabcdefghijklmnopqrstuvwxy
Do not assume that all characters are printable. In other words, values in your output grid may be anything from 0-255. For convenience during development you may use data of your own construction as input. A simple way to create this data is by using printable values.
An example of encoding the values for the byte codes is: Use the highest bit in the byte code for the element above and to the left (northwest) of the current. Use the next lower bit to indicate the neighbor immediately to the right (east) of the last and proceed through the neighbors in a clockwise fashion.
Along the edges of your grid you will have no neighbors. Assume that the empty neighbor elements are NOT equal to the current element.
Bring your code to discussion section on Friday at 9am. Location to be determined. Each student must present code to your classmates. If you have a laptop, bring it to use for your demo. If not, put code where you can get to it. Sometimes we will actually make changes and try them out in class.
First: show code that works even if it isn’t complete.
Objectives:
Modify the Raster Analyzer program from last week.
Optimize it using the methods described in class.
Read in the provided binary file. The header provides the number of rows and columns as 16-bit integers. Here is the description for the file header:
| offset | type | description |
| 0 | 16-bit int | header length |
| 2 | 16-bit int | rows |
| 4 | 16-bit int | columns |
| 6 | 16-bit int | longitude of lower left corner |
| 8 | 16-bit int | latitude of lower left corner |
On style:
Grading:
For this assignment, you would need the recover.c file from here.
The assignment is to try to understand how the recovery program works and comment on style, comments, etc. Take a portion - say one function and re-write it in a way that is more clear. This may only be formatting the text so that it's more readable and adding comments. No one will be judged on syntax AT ALL. No one will be judged on the "correctness" of their comments or efforts to improve readability. If you see something that isn't clear, make a comment to that affect. If you THINK a line of code means something but you're not sure, make a comment and write a line that you think would be more clear to replace it.
What this program actually does: This program recovers the entire contents of a disk drive in FAT16 (a specific disk format that was once used by DOS and Windows) by making a BIOS call that gets each sector of the file and writing it to a new disk. It does this recursively, tracing through all directories and subdirectories.
Each entry in the directory tells whether an entry is a file or a directory and the location of the first sector of the file. There is a table entry (File allocation table or FAT) for each sector that tells where the next sector of the current file is. So if the first sector of the current file is 100, I could look in entry 100 and find the sector number of the next sector of the current file. I can repeat this until the next sector indicates that I should stop.
Grading will be on whether you made a presentation and whether you commented on the presentation of others. Be helpful if you can when speaking to others about their efforts.
Objectives:
We mentioned that we will be asking you to produce a program portfolio, where prospective employers can get an overview all of your projects. This is the first of several assignments in which you will write a program that produces that portfolio. The input to this program will be a file containing information about your projects (a "metadata" file). The output will be one or more XHTML files that, together with the files named in the metadata file, will be the portfolio.
This metadata file includes information about each of your projects. The format of this file is specified in an attached file. Please right-click and choose Save As.. since viewing the .txt file in your browser will hide all the metadata tags. While you may add enhancements to the format, make sure that your program is still able to read in a metadata file specified in the original format.
You need to do the following:
These XHTML files should offer a nice interface for browsing your projects. That is, you should be able to open the index.html file and browse to a page for any one of your projects, where you can see more detailed information and access the source code. The format and presentation of these files are up to you. You may make use of CSS or Javascript. For example, you could transform your metadata into the S5 format to convert them into a slide show.
Grading:
Note:
Or, just get the book. Once you see how you can use the State Design Pattern, you can easily search for other resources on it. Also, the UIUC library has some electronic resources on design patterns.
- Go to Google Print
- Search for "Head First Design Patterns"
- Click on the first result.
- Look for the "Search Within this book" and search for "gumball"
- The results are from a chapter in the book that describes how to use the State Design Pattern to implement a Finite State Machine. Return to this results page to browse almost all of that chapter from the book.
Objectives:
The instructions might be a little confusing, so please read them carefully and ask questions when in doubt.
Your portfolio generator currently generates XHTML that is hard coded for a specific set of known tags with known relations. You are now to extend the functionality of this application by moving much of the data and the definition of the finite state machine to be outside of your source code.
You will do this by:
portfolio: project
project: title, date, author, summary, files, versionhistory
date: day, month, year
files: doc, code
doc: f
code: f
versionhistory: version
version: number, info
portfolio can only contain the project tag as a direct child. The project tag can contain title, date, author, summary, files and versionhistory tags. So this example of a format file tells us the tags that we can expect.
portfolio => h3. That is, this would replace all occurrences of portfolio with h3. This limits what you can do. For instance Latex does not necessarily have the same beginning and end tags. To write a document in Latex, it would look like \begin{document} Some text \end{document}
portfolio:
begin:
end:
project:
begin: <h3>
end: </h3>
title:
begin: <b>
end: </b>
...
....
......
In the above, portfolio was intentionally left without any begin or end tags.
Grading:
Note:
Objective:
You will be given a grid of integer values that represent elevations. We will be working with the same geographic area as before.
There will be values in the terrain attribute data (TAD) from the first assignment that map to various types of water. Since water is flat, you need to scan through the elevation data and flatten the terrain wherever water is indicated in the TAD file. Assume that "square" formed in the elevation data by a given post and the neighbors to the east, north and northeast need to be flattened whenever the TAD value is a water value.
Here is a suggested naive method:
Scan through the grid of TAD values, whenever there is a water value set the elevation of the 4 posts mentioned above to the lowest of the 4 values. This method entails making multiple passes.
This will be a two week assignment. Next week, we will want you to display the results in a graphical form. Sample skeleton code will be given that uses OpenGL and GLUT framework. You may also choose to use any other drawing APIS that you are familiar with.
You will use the TAD from Project 1. The file format remains the same as it was in Project 1. Remember that in the TAD, we have 256 x 256 grids. And of course, you need to know how water is represented. There are two types of water bodies that you need to care about: 0x52 is ocean and 0x41 is inland water.
Finally, you would also need the elevation file (binary file) from here. The data (that means each grid's elevation) consists of 32-bit integers. The header is 128 bytes. The number of rows and columns is at offset 24 bytes, both are 32-bits integers. In this particular implementation, there are 257 rows and 257 columns. The first 2 integers are 32-bit latitude and longitude but the units are 1000ths of a degree (but you do not need to care about this).
CAVEAT: The data in the TDA files are bytes! And the elevations are 32 bit integers.
Here is a picture that should make things clearer.
Every connected body of water should have the same elevation. Notice the "square" of blue grids in the middle of the diagram. All of them should have the same elevation. But what if we have something like the top right corner where we have only one patch of water? Then you must just set the elevation data on its north, northeast and east gird to the level of the water even though there is no corresponding grids on the TAD file. Remember, we are changing values in the elevation file. We use the TAD file just to tell us whether a particular grid is ocean or inland water.
Questions to ponder:
Grading:
Objectives:
As mentioned last week, this week you will create a program that displays a graphical view of the terrain and its elevation. To help you out, I have created a simple GLUT program that draws some lines on the screen. There are lots of comments in the file to help you get started. The sample code that I wrote is in C. And it requires the GLUT libraries. For instructions on how to set up GLUT using Visual Studio .NET, please refer to this site. You may obtain a copy of Visual Studio .NET 2003 from the university by following the instructions here.
Alternatively, you may elect to use any other framework of your choice as long as it accomplishes the minimum requirements of the assignment:
Also, for this assignment, we require you to start using a version control tool. Subversion is one example of this which you all should be familiar with. The instructions which I send last time would be helpful to get you started. However, this time, please create your own repository and do not pollute the one on https://opensvn.csie.org/uiuc_cs242/trunk. You may create a local repository (one that exists on your hdd) or create a new one online using any of the free hosting sites (OpenSVN is one fine example). For a quick start to creating your own repository, refer to this page from the Subversion book.
For those of you who have never used a version control tool before, a good rule of thumb on when to commit your changes would after you have written a function that works correctly. We would like to see at least 3 commits to the repository with decent comments.
Finally, here is the zip file of all the stuff that you need for this assignment. There are 5 elevation files there. You would still use the same TAD file that you have from last week but read in different elevation files for each. This might actually create some rather weird effects. Also, as mentioned last week, you should not code the name of the files; instead, make your program behave like an application and read in the file names (maybe from the command line).
Grading:
Objectives:
As alluded throughout the course, we are once again back to our portfolio project. So, by now you should have a static portfolio page that showcases the projects that you have done throughout this course. This time around, we want to expand on that and make the page less static: by enabling comments.
For examples of threaded comments, please visit slashdot.org. All that we require is that we can reply to comments. That means there is some hierarchy to the comments. If you want, you can also implement sorting by date, comment score, etc.
While the description of the project is simple enough, your main hassle would be dealing with PHP and MySQL (or whatever language or database of your choice). Why? Here are a list of things that you need to keep in mind as you approach this:
Some technologies that you might be interested in trying out:
Next week you will enable filtering for the comments. That way, no one can insert malicious html or javascript that can break your page layout.
Grading:
Objectives:
As alluded throughout the course, we are once again back to our portfolio project. So, by now you should a page that supports some simple form of comments.
However, no one has implemented a filter system for profane terms yet. So, the next step would obviously be to include one. You can make this as elaborate as you like. For instance, you might replace the profane terms with their euphemisms. Or you can just replace parts of them with * for the vowels. Or, you could always do so with more creative ideas. Surf around the web and see how other people have been doing it.
Moreover, it would also be prudent to implement some kind of javascript and html filter so that comments will not break your page layout. There might already be functions to do this in your particular language so do check them out before writing your own version. If you find that your implementation might be more robust, then by all means, write your own.
And since you have an almost complete portfolio online, you would also want an admin page for it. You would want a page where you can quickly view all new comments that have been left. Also, you want to be able to delete comments as well. Additionally, you might want to be able to keep track of frequent viewers to your page based on their IP address, etc.
More importantly, we would also like to see all the projects that we have done so far included in your portfolio.
We want to have more questions and comments during the discussion section. Some guidelines for questions were given in the e-mail that the TA sent out last week. You will also find relevant checklists in Code Complete 2 chapters 31 and 32. Use those as guidelines to help you ask questions. An additional hint: ask the rest how they solved a particular problem that you were having. For instance, if you were having a hard time getting the filtering to work because they might be so many cases to consider, ask them how they did theirs.
This week's assignment is easier to give you ample time to prepare for the next one. In the next assignment, you would have to work with the students in your discussion section to come up with a simple graphics editing program. This would be a form of pair programming where you CANNOT write code unless everyone of your group member is there. This would be an enlightening experience for everyone.
Grading:
Objectives:
Pair Programming:
For this assignment you will pair up with students from your discussion section. Since the afternoon section has 3 students, they will, instead, practice "trio programming". Your group will be in-charge of setting meeting times, project goals, etc that will enable you to succeed in this project.
You will implement a picture editor that is capable, but not limited, to the following features:
This assignment requires not only individual contributions but also group contributions as well. We have released this assignment earlier so that you get a chance to work out suitable meeting times with your group members. Do not worry if you cannot get everything done by the deadline. Show us a working version of what you have accomplished.
While you are free to use any language or framework that you choose, we suggest taking a look at Java and the facilities that it provides. Also, the Java language is one of the languages where it would be simpler to do Pair Programming in since everyone can install the JDK. Here are some links:
Hints:
Grading:
Objectives:
Everyone did a good job last week on their projects. We were so impressed that we decided to extend this project by one more week to see what else you guys can come up with.
Also, since most of you are already familiar with your code and the framework, this would also be a good opportunity to see if you would have any added benefits from pair programming.
We only ask that you implement the undo/redo functionality. You may choose to enable multiple redo/undo levels. Or you may just choose to redo/undo the last action. Of course, if you had any problems with your project last week, now is also the time to fix those minor annoyances.
For people using Java, you might want to take a look at the Java UndoManager. Here is an example on how to use it.
For people using another framework, an easy way to do this would be just to store the last image that the user sees and restore that whenever an undo action is requested. Of course, this is only limited to actions that actually modify the image, not something such as zooming in or out.
For the more ambitious, the best-practice way to implement undo/redo functionality is using the Command pattern. An example of how to do it in Java can be found here.
You will work on a project of your choice within the 4 week time period. Each week you will present your progress in class. You will be evaluated on what you have accomplished for each week.
Since this is your project, you should be enthusiastic about your code and presentation. You should present in a manner that convinces everyone about why your project is a worthwhile endeavor. We will be looking out for the usual suspects in your code:
Also, looking at the lecture slides for November 7 will help you focus on what your program is supposed to do. It is very easy to off track from the original purpose of your program so be sure to review that you are doing frequently.
Post questions, concerns and comments to the class newsgroup at class.cs242