Monday, January 25, 2010
What to do about broken links in this weblog
If the link begins like this:
http://www.nvcc.edu/home/vfitton/whatever
then insert "000storage" in the URL so that it looks like this:
http://www.nvcc.edu/home/vfitton/000storage/whatever
That will fix the ones that can be fixed.
Tuesday, May 5, 2009
201 more on random numbers
This article in Wikipedia explains things well. Recommended! And you can find lists of prime numbers online, too. For a sample of size N, I should think that we'd want a modulus a good bit larger than N, about twice as many digits.
Monday, May 4, 2009
201 a sequence of numbers on TI-84
Do this with the calculator in Sequence mode — use Mode key, then on Function line, choose Seq.
nMin=1
u(n)=u(n-1)*43+200-iPart((u(n-1)*43+200)/17)*17
u(nMin)={5}
To get the u above, see the little u above the 7 key. For n, use the x key.
You can see the results in a table with TblStart=1, delta-Table=1, or in a graph:
nMin=1
nMax=100
PlotStart=1
PlotStep=100
Xmin=1
Xmax=100
Xscl=20
Ymin=-2
Ymax=18
Yscl=5
I read in the TI-83 manual that the screen is 63 pixels high and 95 pixels wide. Haven't tried these routines yet on the TI-89, but I'm sure that they're substantially the same there, excluding the screen dimensions.
What do you suppose makes this sequence so bad, anyway?
201 Exceptions code
Sunday, May 3, 2009
Saturday, April 25, 2009
201 about matrix x vector
[[x'] [[a b c] [[x] [y'] = [d e f] * [y] [1 ]] [0 0 1]] [1]]or several at a time, like this:
[[x1' x2' x3'] [[a b c] [[x1 x2 x3] [y1' x2' x3'] = [d e f] * [y1 y2 y3] [ 1 1 1 ]] [0 0 1]] [ 1 1 1]]If you choose the second method, be sure to have all ones in the bottom row.
There are several other links related to this project below — don't miss them!
a blast from the past
And I ran into a picture of my second computer. Wow! I used that one and pieces of it for years and years. Here it is:
When it was closed, the keyboard (which could be detached, too) formed the bottom of its suitcase-like enclosure. It weighed 25 pounds, at least, and more in airports. You can see here that one of the floppy drives has been replaced with a hard drive — 30 MB was the size of my first one, and it was a finger-smashing proposition to get it into this machine, for everything was so tightly arranged. The monchrome screen was amber rather than green: cool!
This was my second bona-fide computer, and it cost $2500, such a deal, I thought, with two floppies and 256K RAM. I added a serial port for an extra $100. I loved it.
201 my sample Tri program
java -jar Tri.jar < mydata.txtEnjoy!
Friday, April 24, 2009
201 how to read Tri data
- read a string
- examine the first character of the string with String.charAt(0), which looks at the first character stored with the string
- then, for characters 'S', 'T', and 'R', use a switch on that character
Thursday, April 23, 2009
201 very sleepy
try { Thread.currentThread().sleep(millis); }
catch (InterruptedException e)
{ System.out.println("Error sleeping"); }
This code is seen in StdDraw.
Why put the program to sleep? For animation: otherwise, it might move too fast. If you have a sequence of instructions, possibly in a loop, that you want to execute more slowly so you can admire your work at a humane pace, put a few milliseconds of sleep-time between them.
Both the Thread object and the InterruptedException object are in java.lang, so you don't have to import them. We will talk about exceptions next week.
Wednesday, April 22, 2009
201 code, hooray
Monday, April 20, 2009
185 Week 14: Javadoc
Here's the best reasonably short description I've been able to find of this program, which is called javadoc. It resides in the same folder as your other Java binaries.
See if you can produce the Javadoc for one of the booksite's standard I/O library files. Plan to comment your code in this fashion in the future.
I will add some other links during class.
Wednesday, April 15, 2009
201 tracing function calls
Monday, April 13, 2009
Week 13: programs jar and ant
Program ant is like make, which we did last week, only updated. Please do steps 1 to 6 of this second lab. Ant is under the hood of giant IDEs like NetBeans and Eclipse, as well as Microsoft Visual La-la-la.
Monday, April 6, 2009
Week 12 (?): more complex builds and automating builds, part 1
link 1 Linux make for C++
link 2 a C++ program (very small Skeleton) for Linux
link 3 a makefile for Java and other languages
link 4 and a batch file (Windows) for Java
link 5 from IBM, an article about standard Java directory hierarchy
Monday, March 30, 2009
Week 11: matrix operations
Here's code for an interface. Please use it.
It would be a good idea to check your caluclations using a calculator that can handle matrix multiplication.
Monday, March 23, 2009
Week 10: bash shell programming
Your bash shell has a configuration which is naturally specified in files. Learn what they are and see a few samples. [2]
From a fab book [3] all about programming the most popular Unix shells:
The fundamental grammar of the bash shell: it's very important, and this is a concise description.
See the chapter on Interactive Bash Shell. (As opposed to one that's running in background, where you can't see it.) Check its expanded table of contents at the left of your browser window and choose the topics from this chapter that interest you most. Here are the ones that I consider most essential:
- intro
- environment
- command line
- metacharacters
- quoting
- command substitution
- redirection
- pipes
- built-in commands
From the chapter on Programming the Bash Shell, try running the first few programs and making simple changes to them.
In particular, see Lab 56: Getting User Input. Write the program nosy, item 1 on this page, and send it to me.
Scan the appendix Useful Linux Utilities for Shell Programmers. You can use all of them as commands in any bash script.
[1] Moving to Linux: Kiss the Blue Screen of Death Goodbye! by Marcel Gagne. Mostly about GUI on Linux.
[2] Unix Visual Quickstart Guide by Ray and Ray.
[3] Unix Shells by Example by Ellie Quigley. It's the bomb.
I also like this book, which has an easy-going attitude: Linux Scripting for Bash.
Friday, March 20, 2009
Graphics links
In case you don't have a calculator with matrix ops at hand, try this IT-84 calculator emulator — useful for checking your results.
Monday, March 16, 2009
Week 9: make a web page so we can put Java code online
Here's Sun's starter applet, which says Hello, naturally.
Here are simple web pages zero, one, bio, cycling that I wrote so that you can do View > Source in the browser menu and see some simple HTML.
And on an old weblog that I wrote for another class, you can find all sorts of how-to: look in the neighborhood of January and February of 2008. One how-to that will be especially helpful is on uploading to the student web space.
Wednesday, March 4, 2009
You're invited to outer space
The American Astronautical Society is having its annual Goddard Memorial Symposium, which takes place in Greenbelt, Maryland on Tuesday – Thursday, March 10 – 12, and you're invited. Just $30 for students — it's a steal! This year's theme is sustainable space exploration. See the student rate at the very end of the registration form.
Monday, March 2, 2009
Ubuntu guide worth the download
Although a lot of it is about GUI and we don't have GUI in the lab, remember that you can install Ubuntu Linux on your home machine essentially risk-free and easily with Wubi. Then you'll have both the GUI and the command line to work with. Chapter 5 of this book is a sane reference to the command line without the usual fire-hose effect.
185 a few good Linux tutorials
Let us start with the college library's subscription to Safari, the greatest resource since the library itself.
IBM's New to Linux" page
Linux Magazine's Wizard Boot Camp — ten articles
A giant Linux tutorial at IBM. Here are our high-priority items, wherever you find them:
Topic 103: GNU and UNIX commands
1.103.1 Work on the command line
1.103.2 Process text streams using filters
1.103.3 Perform basic file management
1.103.4 Use streams, pipes, and redirects
1.103.5 Create, monitor, and kill processes
Topic 104: Devices, Linux filesystems, and the Filesystem Hierarchy Standard
1.104.5 Use file permissions to control access to files
1.104.6 Manage file ownership
1.104.7 Create and change hard and symbolic links
1.104.8 Find system files and place files in the correct location
Topic 109: Shells, scripting, programming, and compiling
1.109.1 Customize and use the shell environment
1.109.2 Customize or write simple scripts
snow on 3/2/09
is there snow? March 2, 2009
Meanwhile, I assume that they assume, optimistically, that we can all get there before dark. That will be a challenge for me!
Monday, February 23, 2009
185 Linux CLI today
Linux/Unix machines offer a variety of choices for command shells: a popular one is bash, which stands for Bourne-again shell, which followed the Bourne shell. (These Unix guys are a riot!) Bash is a very popular choice and is used in Ubuntu Linux as well as the Macintosh OS.
Here's the handout for today, and a few links follow:
how many bash references can you use, anyway? put the word bashin the search box
exploring the shell: that's for us!
here's a chapter on aliases: understanding these will be very valuable
reference comparing Windows CLI and bash; this guy has a lot of good ones, so no surprise that he teaches in a community college!
long list of bash commands
bash commands sorted by type
185 some more Windows CLI links
from Windows XP in a Nutshell, a long list of commands that you can run by name at the Run prompt in the Start menu — knowing some of these can save you a lot of mousing around
same thing, run commands, different format
more of the same, command prompt and batch files from one of the always great "Unleashed" books
Thursday, February 12, 2009
"Open Command Window here" and lots of other things
Sunday, February 8, 2009
185 week 4
This week, we will make a somewhat more complex version of the same.
Java projects generally have a number of directories associated with them. IDEs vary in which ones they set up, but the following is a skeleton of what you will see:
project
|
-------------------------------------------
| | | |
bin src lib doc
In the project folder, we have:
- bin for binaries, already compiled files with names *.class
- src for source files, *.java
- lib for library files
- doc for documentation
- Make a file for a project, something you've written or downloaded. I'll call mine project.
- Note lower case for project name. More about project names later.
- In the project directory, make two subdirectories, bin and src.
- Note the name of my program is Whatever.
- Modify the batch file go.bat from last week's notes so that, from a command line opened in the project directory, it will do the following:
- If file src\Whatever.java does not exist, print a message saying so and end the program.
- If file bin\Whatever.class exists, erase it.
- Compile the file src\Whatever.java file named on the command line, with result
going to bin\Whatever.class. Here is the nut of a correct command line to use, exclusive of path to JavaHome:
javac -d bin -cp .;.\src src\Whatever.java
There is a correction in the line above.
- If the compilation is not successful, print a suitable message and end the program.
- Otherwise, run bin\Whatever.class.
- If file src\Whatever.java does not exist, print a message saying so and end the program.
- javac options and their meanings
- how a batch file tests for the existence of another file (if exist)
- how to make directories, erase files, ...
Check the links at the end of the week 3 notes.
Monday, January 26, 2009
Projects 0 and 1
Project 1 includes three programs, too:
- 1.2.27, values from a Gaussian, or normal, distribution of random numbers
- 1.2.29, a program to determine what day of the week a given date falls on
- 1.2.34, find the min, max, and average of five numbers from a uniform random distribution — without using an if statement
Information on how to submit programs and other things you need to know about it will come next week.
185 week 2
- examine code standards from Sun website
- use Skeleton programs on instructor's website
- write programs using Math library functions on integer and double variables
Details:
- These code standards from Sun haven't been updated in a long time, but then, they were good to begin with. Much of this document refers to things that we haven't done yet. Meanwhile, please take ten minutes or so for the parts that do make sense to us now. You should return to them several times over the semester.
- Check out updated Skeleton programs: SkelHello, SkelCL (CL for command-line inputs), and Skeleton, our general-purpose framework. If the meaning of something isn't clear to you, get friendlier with the person next to you. Note the components of the general-purpose Skeleton:
- comment with author's name, date, and purpose of the program
- an introduction that tells the user just what the program is about
- civil prompts for user input
- coherent labels for the output
- whitespace for legibility all around
- an opportunity for the user to try the program again with new inputs
- notice of the program's ending
- comment with author's name, date, and purpose of the program
- Check the Sun Java API docs for the Math class. Notice the signatures for its methods. Many methods have more than one signature because they are suitable for more than one kind of input.
- Write and test programs in which you combine elements of Skeleton and the Math class to do the following:
- program Circle.java: get a positive integer from the user and report the area of a circle whose radius is that integer
- program Pythagoras.java: get a number from the user — let's suppose you call it x in your program — and compute and show the value of sin^2(x) + cos^2(x).
- program Quadratic.java: get three values from the user and, supposing that they are the coefficients of a quadratic equation ax^2 + bx + c = 0, find the roots of the equation.
- program Circle.java: get a positive integer from the user and report the area of a circle whose radius is that integer
Wednesday, January 21, 2009
Tuesday, January 13, 2009
Welcome Spring 2009
Whichever way you go, it is important to install the Java JDK before installing the IDE, or integrated development environment, so that the IDE can configure itself properly.
The first lab, from yesterday, uses the editor TextPad and has (what I hope are) corrections and clarifications in italics, and the second, from the fall semester, uses not jGRASP but rather DrJava. No harm in trying all three.
Thursday, December 18, 2008
SequenceUI and Sequence skeleton
SequenceUI: watch this space
Sunday, December 14, 2008
Sequence class
I suggest that you start your work with a Sequence.java file with a main method that allows you to test the methods very briefly with manual input, then expand this to a SequenceUI.java that imports methods from Sequence and conducts more elaborate tests. I will provide frameworks for both of these classes. Here (without its methods :-) is the Sequence that I showed in class the other day: click Note that Node is a private class member of Sequence. See examples on page 568 and 578 of the text.
And here is the original assignment: click
----------------------
Sequence API
----------------------
<< constructor >>
returns a Sequence object
+add(item:int):void
adds item to Sequence
so that Sequence is always in
ascending order
+display( ):void
displays items of Sequence on output device
+get(pos:int):int
returns value of item at position pos
+find(k:int):int
returns position of first item having value k
in Sequence
+length( ):int
returns number of items in Sequence
+count(k:int):int
returns number of items having value k in Sequence
+delete(pos:int):void
deletes item at position pos from Sequence
+remove(k:int):void
removes all occurrences of items with value k
+removeAll( ):void
removes all items from Sequence
+equals(s2:Sequence):boolean
returns true if number of items and values of items
in Sequence s2 are same as those of caller
+copy( ):Sequence
returns a deep copy of caller
makes new Sequence object
for each node in caller
make new node
copy value of caller's node
add new node to new Sequence
return the new Sequence
Extra props go to a student who supplies a method that displays the reverse of a Sequence: e.g., the reverse of {1 2 3} is {3 2 1}. The implementation is completely up to the student!
Wednesday, December 10, 2008
FYI final exam schedule
Tuesday, December 9, 2008
100 last lab!
Sunday, December 7, 2008
201 preliminary on final project
We will have a list of integers kept in ascending order. If you want to start thinking about it now, you can write a program that keeps the contents of a small array in order. Write a loop that [1] either gets a new integer from the user or generates a random integer, [2] puts the new integer in its correct place in the list, [3] then displays the current contents of the list. You'll need a way to get out of the loop, too. That's enough for now.
On Tuesday, we will talk about other methods that every list contains, such as delete an item, find out whether the list contains X, report its size, etc. You can look at the List API in the Java docs for some ideas of typical list methods.
However! Note that your program will not include objects that are already part of Java: you will write all of the code that creates and maintains the list. And your program will keep the list in order with every new entry. Since it's never out of order, there will be no sorting.
Wednesday, November 26, 2008
100 more X experience
- Check out the Cygwin installation that's already on your machine in the lab. Cygwin is a Windows application that offers a Linux- or Unix-like look and feel.
- Read about how to install and use Cygwin
here. Since Cygwin is already on your lab machine (I make this claim with fingers crossed), you don't need to read the first two pages today. Still, the installation routine is interesting, and you might like to see how it works — up through step 9.
- Jump to item 11 to work with Cygwin as a terminal app.
- This week, use Cygwin rather than Xming (which we used last week) as your local X handler. We'll use the secure shell program built into Cygwin rather than PuTTY. Cygwin also offers more window managers than our Linux installation at wocsc.
- To establish the universality of our graphics programs, copy one to wocsc and run it remotely from your Cygwin session. Use the class RandomPoints on page 228 of the text. You can cut and paste it from this pdf from the authors' PowerPoints.
- When you have RandomPoints running in an X window driven by wocsc, show it to the instructor.
Tuesday, November 25, 2008
100 X Window System
- First we need to discuss X as a client/server system. We will be running programs as clients of an X server on wocsc.nvcc.edu: it will send commands to our machines, which will draw according to the commands. See the end of the Wikipedia article's section on the X design for a sketch of this scenario. Please scroll through the entire article.
- We also need a server on our own machines, to send and receive X commands with both the wocsc server and us. We will use Xming. Please scroll through the author's description of it.
- The only piece of Xming that we absolutely have to have is the public domain release of Xming. Get the fonts later, if you want.
- The default install options for Xming will work fine. It would be a good idea to allow the program to create a desktop icon for Xlaunch. You don't need one for Xming itself. Do not launch Xming at the end of the installation.
- Use the Xlaunch icon that should be on your desktop. In the Display settings window, choose Fullscreen for the full-bore X experience.
- In the Session type window, choose Start a program.
- In Start program, accept xterm and choose Run remote using PuTTY. Not to worry, PuTTY was installed along with X. You will connect to computer wocsc.nvcc.edu, natch, and you know your username, I trust.
- Additional parameters: none.
- Give your configuration a name, such as wocscFS, so that it's convenient to use it again. Take care to put it on your desktop.
- Click yes on the Security alert.
- Et voila, your first X session with program xterm running. You're connected to wocsc.
- Welcome to 1984! This distinctive look screams geek.
- You're at wocsc. Notice the behavior of the cursor. Check your mail, do whoami, pwd, ps, ps -e, etc.
- Can you move the xterm window? Ha-ha! You have no window manager! Ha-ha! Enter twm & in the xterm window to start one. You get a lot of font messages, then an old-fashioned window manager. Look up twm in Safari if you would like to learn how to set all of its settings.
- Enter xeyes &. Enter oclock &. Enter xclock &. Mmmm, what fun!
- Close Xming with an exit in the xterm window, or nuke it in the system tray. Go back to the Xming site and get the fonts, install them, then repeat the above steps. In your xterm window, enter emacs &. This is one of the word processors over which religious wars are fought.
- Close your X session altogether, then start a new one, and this time in the xterm window, enter metacity. This is a very lightweight window manager. For links to others, visit this page. Geek heaven! These are not available on our server, but you can have them at home.
- Back in X, enter nautilus & in the xterm window. Things are looking good...
- Actually, Metacity is so light that it is not very capable, compared to other GUIs. That's one of the good things about it, for those who love it. Here's the readme.
- There are heavyweight GUIs, too. Including whole operating systems. You can emulate *nix on a Windows box with Cygwin. This is a Windows application itself, so it's not necessarily fast, but it's very safe and a very good workalike.
And the latest cool, very cool install for Linux alongside Windows that I have seen is Wubi.
Metacity readme
http://svn.gnome.org/viewvc/metacity/trunk/README?view=markup
Tuesday, November 18, 2008
100 Ant day revised after class
See below an addition made after class meeting on November 18.
Today's work is about automating builds. We will consider building both from the command line and the method used in IDEs such as NetBeans, and we will examine customary directory structures for Java programming.
- Last week we talked about make — old school again! — and XML, which is not old school.
- Ant is a program from the Apache Software Foundation, an outfit that makes open-source software. Ant reads a script called build.xml for instructions on compiling and packaging your Java project. (It can be used in other programming environments, too.) This straightforward article discusses first steps in Ant, building — natch — Hello, World.
Carry out this Hello project on the wocsc Linux server. You should find SecureShell ready to go on your desktop.
- From the prompt, do ant -version to ensure that Ant is there and which ant to see where it is.
- Ant expects certain environment variables. Set them in this fashion:
export ANT_HOME=/usr/bin/ant export JAVA_HOME=/usr/java/jdk1.6.0 export PATH=${PATH}:${ANT_HOME}/binNote that there are no slashes at the ends of the environment variables. Also, you might add these commands to your .bashrc so they'll already be there.
- Be sure to give due attention to the commands for construction of directories in the Hello doc.
- Note the targets, too.
- Note that in the bash shell, the command to make a new directory is mkdir.
- From the prompt, do ant -version to ensure that Ant is there and which ant to see where it is.
- Next, the same thing on Windows — from the command line.
- Look for Ant in your c:Program Files\NetBeans\java2 directory.
- Make a little batch file in your working directory — antprep.bat would be an OK name — that sets environment variables:
set ANT_HOME=path_to_Ant_top set JAVA_HOME=path_to_Java set PATH=%PATH%;%JAVA_HOME%;%ANT_HOME%\bin
- Addition:
Ant expects short, old-fashioned file and directory names with no more than 8 + 3 characters in the environment variables ANT_HOME and JAVA_HOME. Note that these environment variables are used by Ant, not required by Java or the OS.
For example, the home directory on the machine I'm using now has two names, both unique: "C:\Documents and Settings\vfitton" or "C:\DOCUME~1\VFITTON". Every pathname on the system has to be unique. Windows uses twiddles and digits to make short names for backwards compatibility with legacy programs. (I have no idea why Ant insists on them, too.)
Find out what the short appropriate pathnames to your ANT_HOME and JAVA_HOME are by using the command shell (from the Run command) rather than cmd and then crawling along the paths from root to finish.
- Carry on with the entire Hello project through "Using external libraries."
- Look for Ant in your c:Program Files\NetBeans\java2 directory.
- This tutorial from TechTracer is more complex than what we need, but the directory structure that the writer proposes will interest you.
Notice what look like OS command shell commands are embedded in the Ant script, in the form <command />, about halfway down the page. They're actually Ant commands — the article at this JavaWorld link lists all of them.
- Break time: Check out this great Java resources page at IBM developerWorks. As the man says, "Information overload is a real problem for Java language developers."
- Speaking of information overload, you will love Refcardz.
- When you use NetBeans, it builds and runs an Ant file for you. Do the same Hello in NetBeans and then compare the Ant result with what you did by hand. (You need to understand it both ways.)
- NetBeans creates files that are about your program rather than a part of it; this is called metadata. You can see such files in the Files window rather than the Project window.
- You will find build.xml much shorter than you expect.
- There are other .xml files in your project's nbproject folder. Check them out, too. Observe the targets, the variables created, and the dependencies. Lots to learn!
- NetBeans creates files that are about your program rather than a part of it; this is called metadata. You can see such files in the Files window rather than the Project window.
- Examine the structure and contents of the Ant folder. Read its batch files.
- Try the Linux make on a simple C++ program. Here are a how-to and a what.
Saturday, November 15, 2008
Friday, November 14, 2008
201 demo code for PolygonUI
Here's what I did:
- Created a new Project / Java / Java Application, changed the default project name, and UNCHECKED the "Create Main Class" checkbox.
- Right-clicked on the default package under the Source Packages and changed its name.
- Right-clicked on the newly named package and added to it a New JPanel Form. NetBeans created a class file that extends JPanel and tells Java how to customize a panel for my UI.
- Added a button, text field, and label for a very rudimentary UI. I changed their names with a right-click in the Inspector at the left: one of the choices on the menu is Change Variable Name.
- Added a few variables at the top of the class definition.
- Added import statements each time that the NetBeans UI asked me to.
- Right-clicked both the panel and the button to add mouse event handlers.
- Added main( ) and paintComponent( ) methods to the source.
Having tried many variations with JFrame and JPanel, I decided to just to draw a fake pane that you won't see until the program runs. I have some ideas about more elegant ways to draw on a panel/frame combination, but hey — I needed to get this baby done!
201 new GUI code
I have been working on two things:
The first is a hybrid Skeleton that combines the use of the Swing/AWT palettes provided in NetBeans with drawing ops, called painting in Java, that I used in samples OneBlob and FloppyLine. (For those, I did use the NetBeans IDE, which was very convenient, but not the palette: all of my objects are explicitly drawn by my code, not by code auto-generated by NetBeans.) I probably won't finish this until late this afternoon. Looks like not everyone wants to do it:
This lesson describes custom painting in Swing. Many programs will get by just fine without writing their own painting code; they will simply use the standard GUI components that are already available in the Swing API. But if you need specific control over how your graphics are drawn, then this lesson is for you. (That's the lesson cited in OneBlob code.)
The second item, which Mr. VS and I discussed after class, is a way of painting in a JPanel that is an instance variable owned by a JFrame, with these created using a NetBeans JFrame program and the Swing palette tools. I don't think that this is going to work. From what I have seen so far, the panel needs to be in a class of its own so that it can extend JPanel. This is because the paintComponent method needs to be called for a JComponent, and JFrame is an awt.Component, not a JComponent.
However, the relationship can work in the other direction, with the top class being an extension of JPanel whose main( ) method creates a JFrame. And, for another variation, back to OneBlob, which class owns the main( ) method and the JFrame (in a second method), and a second class in the same file, an extension of JPanel, has the painComponent( ) method. Oops, I meant paintComponent( ), I think.
And Mr. F is working on a third plan using a Canvas object. More power to him!
You can always use the authors' StdDraw, too. That would save all of us a whole lot of cycles. What have we got against it?
This article tells more about painting with both AWT and Swing than I really wanted to know.
Friday, November 7, 2008
201 demo code for Point class
Tuesday, November 4, 2008
100 Eclipse
Last week we worked with NetBeans, an IDE produced by Sun, the producers of Java. Today we work with an IDE that's substantially more popular in industry, Eclipse, which was developed by IBM and a few years later donated to the open-source world.
- See if there's already an Eclipse directory on your machine. It's probably in C:\eclipse. Since it's all Java and not integrated into the Windows registry, it's safe simply to delete the directory and start over.
- Go to eclipse.org and look around. Find and get the download labeled Eclipse IDE for Java Developers (85 MB). Install it.
- Go through both the Hello, World and Hello, World SWT tutorials. Check out the directory structures.
- Scan the article "SWT, Swing or AWT: Which is right for you?" at IBM's developerWorks. Take some time while you're there to check out a few other topics that interest you.
- Now for a GUI for Eclipse: I recommend Jigloo. You can install it manually by unzipping it into your Eclipse plug-ins directory or by using Eclipse's Software Updates facility on the Help menu. I find the latter more cumbersome, but still interesting.
- Jigloo can handle both Swing and SWT: clever Jigloo! Do the Jigloo Swing tutorial.
- In the time that's left, can you reproduce one of the sliders from last week? Or some dots? Or something more profound? Amaze us all.
Saturday, November 1, 2008
for VMATYC, November 1, 2008
My favorite student projects this year have been Taylor series computations and drawing sine roses. At the moment we're working on scaling and rotating polygons with affine transformations. Our most recent lab, which you can find on this site, was practice with a much more complex program edit / compile / run environment for making graphical user interfaces.
I love my weblog — it's filled with cool stuff!
Tuesday, October 28, 2008
201 next assignment: Polygon, due 11/18/08
- it uses a Java GUI
- it has a button labeled Clear to clear the drawing screen
- it instructs the user to click on the screen to set vertices for a convex polygon and draw big dots where the vertices are
- when the user clicks sufficiently near the first dot, the polygon is closed
- it reports the perimeter and area of the polygon
- it allows the user to scale (make larger or smaller) or rotate the polygon using GUI controls
- it uses a Matrix library that the student writes and affine transformations as shown in class to accomplish the scaling and rotating
- it updates the perimeter and area of the polygon as the user changes the scale
I'd get started now if I were you!
100 NetBeans day
[0] Ask me to talk about "waterfall" programming versus event-driven programming.
[1] Check the NetBeans version on your machine. If it's not 6.1, then go to netbeans.org to download the latest NetBeans (SE version, about 30 MB). If it is, go to the website anyway just to see what's around.
[2] Write Hello, world in NetBeans — tutorial here. The primary difference between this and the Hello we've written before is the complexity of the directory structure. Explore the directories: this structure is typical.
[3] never mind
[4] Now a GUI app that does a little bit of arithmetic and acquaints you with GUI objects: click here.
[5] Here's another simple GUI app that converts between temperature scales: click here. Follow the "programmer's perspective" trail.
[6] I wrote two more programs after this. The first one added a slider and a text box in a frame in the page (screenshot) and initialized the text box to zero. When the user moves the slider back and forth, the value shown in the box changes from -50 to 50.
The second responds to mouse clicks by drawing a dot where the mouse is clicked (screenshot). For this I used the MouseReleased event.
I studied the code that NetBeans wrote for my programs (including the grayed-out code) to figure out how to do this.
I think that once you can do these, you can do the Polygon program.
Sunday, October 26, 2008
201 next assignment (polygon operations)
On Tuesday we'll use tutorials from netbeans.org to write both console and GUI apps. (We'll use the Java SE version of NetBeans.) And I'll show you a few short programs that I've written with bits of GUI that you can use to make an interface that allows the user to click the mouse to set the vertices of a polygon and then scale it and turn it using sliders or other gadgets.
We'll get experience with a bona-fide complex modern IDE and learn to use typical ready-made object relationships for a GUI at the same time that we are talking about our own OO constructions in class.
So yes, we're going on with the roll-our-own polygon routines. We'll certainly need matrix operations for these, so you can get started right away on the Matrix ops whose API for Matrix that I pointed out in the book. You'll need a main( ) method in Matrix written for testing only. It should have a console interface similar to ones shown in 2.2: from the console, or by redirection from a file, read two values M and N representing number of rows and number of columns, then M rows of N numbers. That's for one matrix. Adapt this model for vector * matrix ops, matrix * matrix ops, etc. Check the answers with a calculator.
We'll talk on Tuesday about just how to test the Matrix API, which will be due on Thursday, November 6, as well as expectations (including due date) for the polygon program.
This is going to be fun!
Tuesday, October 21, 2008
Alias for updated Java on Linux server
alias java='/usr/java/jdk1.6.0/bin/java' alias javac='/usr/java/jdk1.6.0/bin/javac'
100 Making an applet
Our work today:
- experiment with HTML (the simple script that browsers read)
- make a simple web page with Hello, world
- make a simple web page with two (or more) rectangles
- convert your sine rose program so that it runs in an applet using Graphics library methods
After you have done all of the above, you'll be ready to jazz up your web page with color etc.:
Very simple sample pages written to show HTML rudiments — do View /Source to see how the code works — pageZero, pageOne, all about me, and links for cyclists
Reference pages for HTML, for color one two, and tutorials galore
Monday, October 20, 2008
assignment in 2.1
It is very important to break the program into its component tasks and write a separate method for each. Having done that, it is then OK to put all of the methods for this program in one file, Calendar.java.
Saturday, October 11, 2008
Omnium gatherum
next programming assignment: section 1.5, a rose in polar coordinates
super math references for computer graphics, from the University of Waterloo in Ontario and from SIGGRAPH, a subset of the Association for Computing Machinery, the professional organization for computer scientists
from UNC's shareware site, you can download the SecureShell client that we used in the lab for reaching our Linux server (wocsc.nvcc.edu); you can also use the very popular PuTTY
this calculator emulator works well for me
Mr. VS asserts that in class weeks and weeks ago I mentioned the Java command System.exit( ) which has closed his graphics window handily.
IBM's roadmap to Linux; see especially part 2 (of many) about the console — the links at the end are terrific!
Tuesday, October 7, 2008
assignment for Thursday, October 9
We want to use it in back-and-forth interaction with a command window: for example, suppose that we give commands for a sine rose, then draw it, then close the drawing and loop to do these steps again with different parameters for the rose. Just because it isn't obvious how to do this doesn't mean that we can't.
Here's a formatted copy to print: click (or print your own with colors, and don't forget line numbers). Take at least an hour to study it, and bring your notes to class on Thursday. Prepare to discuss the following:
- methods
- some are overloaded
- some are private, some public
- data declared (and usually defined) in the class
- objects from standard Java classes
- these are declared, e.g.,
GeneralPath path = new GeneralPath(); - from which classes do they come?
- these are declared, e.g.,
- patterns in the code: many methods end the same way
Saturday, October 4, 2008
my Taylor series results
I have tested values from all four quadrants of the plane in a variety of magnitudes, although only a few are shown here. You can compare results with the ones a calculator gives you. Note that a TI-89 will calculate a Taylor polynomial of given degree; there are TI-89 emulators online that look and work just like the real thing.
The program that you should submit needs only show the bit that follows "recap" up to "do another": you may wish to write two complete programs, one with all of the detail and a second that cuts the detail after the first one is correct. In that case, submit two .jars, one called Taylor.jar and the other, TaylorDetail.jar. Include the sources in both cases.
Thursday, October 2, 2008
Skeleton3.java here
/**
* program Skel3
* it just loops and loops
* it's a safe start for a small Java program
* modified to use Sedgewick/Wayne StdIn and StdOut classes
*
* files StdIn.class, StdOut.class assumed to be
* either in same directory or in classpath
*
* @date fall 2008
* @author N V Fitton, vfitton@nvcc.edu
*/
public class Skel3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// string object for user input to control loop
String keysIn;
// replace with your introduction
StdOut.println("\n\t Program introduction...");
do
{
// --- snip ---------------------------------
// --- replace with your programming exercise
StdOut.println("\n\t Program body...\n");
// --- snip ---------------------------------
StdOut.print("\n\t Do it again [y/n]? ");
keysIn = StdIn.readString();
}
while (keysIn.startsWith("y") || keysIn.startsWith("Y"));
// end do loop
// remove whatever remains in StdIn:
// at minimum, there's still a newline
while ((StdIn.readChar()) != '\n')
;
StdOut.print( "\n\t Program ending."
+ " Please press the Enter key...");
while ((StdIn.readChar()) != '\n')
;
}
}
Sunday, September 28, 2008
201 error in book on Taylor series
sin x = x - x^3/3! + x^5/5! - x^7/7! + ...
cos x = 1 - x^2/2! + x^4/4! - x^6/6! + ...
Notice that cos x is the derivative of sin x.
Although these approximations for sin x and cos x are true for all x, they are best "near 0," according to our calculus book. How near? Run some experiments and see what you think. Any good approximation for sin x and cos x should certainly yield sin^2(x) + cos^2(x) = 0, no? And you can certainly test nonzero values for x for which you already know the sine and cosine.
Take advantage of the periodicity of sin x, cos x: Use modular division and built-in constant Math.PI to translate any real x into a value near zero with the same sine and cosine. Although modular division in math is defined only for integers, in Java it works on reals, too.
What the CS book calls the Taylor series, our calculus book calls the Maclaurin series, a special case of Taylor for functions evaluated at zero. The general Taylor series is a more complicated expression. You get to study it in Calculus II.
Saturday, September 27, 2008
.jar extracts
Thursday, September 25, 2008
100 making a .jar file
First, if the manifest file doesn't have a newline (a.k.a. return) at the end of a line, it won't be read by the system.
Second, with Java 6 or later, you can specify an entry point, that is, class with a main( ) method, for your program from the jar command line. Suppose thatthe following: you are combining all the .class files in a directory into your .jar, your application will be called MyApp, and file ReallyMain.java contains the main( ) method that you want to use. You can say this:
jar cfe MyApp.jar ReallyMain *.class
Whew. Read all you could want to know about it here, one little page of Sun's mega-tutorial on all things Java.
Friday, September 19, 2008
Thursday, September 18, 2008
Free and Open Source Software, etc.
Related references: Software Freedom Day looks to be a bigger deal in some other countries than it is locally. The Free and Open Source Software movement is one from whose ideas I certainly benefit every day, but I'm not doctrinaire about it. The group gNewSense is devoted to promoting software installations that are 100% free of commercial software.
The thing on the OpenSolaris discs that interests me most is Virtual Box, a tool for allowing several different operating systems to be installed on one machine. VMware offers a version free to small-timers like me, too: I'm not planning to host my own website or manage a network, so either of these should work fine. I'd like to have both Windows and Linux (or any other Unix-like system, such as OpenSolaris) on one machine without the drag to sleepwalking speed for both operating systems, which is what I've experienced with emulators.
Let you know if I ever get around to it. For now I keep separate machines, and they're both working fine. Boy, do I feel rich with two computers on my desk. Confused, sometimes, too.
Thursday, September 11, 2008
201 homework 1.3, part one
Two ways to go:
[1] Get N from the command line. Call this program Cboard.java.
[2] Use SkeletonTwo for Cboard2.java as a foundation and get N within the program. (This will require some extra study.) Loop around so that the user can try various values of N.
Extra credit. Make a bigger checkerboard, for example, with each square made something like this:
***
***
***
Do arithmetic with N so that the individual squares are of the largest size possible (1-by-1, 2-by-2, etc.) without making too long a line and messing up the console screen.
Whether you choose option 1 or 2, make sure that the program responds graciously to inputs that don't make good checkerboards.
Due at 4:30 pm sharp on Tuesday. Bring a hard copy to class (or fax it) and send code in an e-mail, subject "201 homeword 1.3 checkerboard," before class.
Next homeworks: 1.3.37 trig functions, 1.4.28 find duplicates, 1.4.30 minesweeper; due dates not yet determined.
Quiz, sections 1.1 to 1.4, on Thursday, September 18.
if I had $3,995 (to spare)
"Embedded systems" is a name for putting microprocessors in cars, telephones, toasters, etc. An embedded system has either no operating system or what's called a real-time operating system (RTOS). It's in an eternal loop, waiting for one of its sensors to say hey, attend to me.
The embedded systems counterpart to "hello, world" might be the blink of an LED.
Tuesday, September 9, 2008
Monday, September 8, 2008
Saturday, September 6, 2008
Submitting homework 1.2
Friday, September 5, 2008
A few reviews of Google's Chrome browser
Don't know much about Microsoft's new browser, IE8; some in my family (not me) are still reeling from IE7.
Thursday, September 4, 2008
201 homework 1.2
1.2.28 InOrder.java, a program that takes three double values x, y, and z as command-line parameters and prints true if the values are strictly ascending or descending (x < y < z or x > y > z), and false otherwise.
1.2.34 ThreeSort.java, a program that takes three int values from the command line and prints them in ascending order, using Math.min( ) and Math.max( ).
Ground rule: No IF statements! You may use only as much Java as you see in sections 1.1 and 1.2 of the book.
E-mail subject line: 201 homework 1.2
This assignment is due by 4:30 p.m. on Tuesday, September 9. Submit three source-code attachments, named as above, to one e-mail to the instructor, and bring a hard copy of each to the CSC 100 meeting at 4:30. If you are unable to attend class, fax your work to 703-845-6006 before 4:30.
Here is a wee sample program indicating the kinds of comments, spacing, mnemonic names, and overall clarity expected in your work.
See also SkeletonTwo.java (above) for a sample of what should be commented and how.
I will post standards for your programs by the close of business on Friday. Meanwhile, you can get an idea of what the standards will be from these old standards: click for grade sheet, click for standards. Click also for overall policies.
Wednesday, September 3, 2008
201 about logic
Item 2. We saw three logical functions of two variables: NOT, AND, and OR. There are in fact sixteen such functions in all. Why?
These three are universal, which means that you can find an equivalent for any of the other thirteen functions using AND, OR, and NOT.
Also, NOT and AND are universal, so you can make an OR out of just NOTs and ANDs. And you can make an AND out of NOTs and ORs.
One of the sixteen is called NAND: p NAND q is the NOT of p AND q. NAND is universal all by itself. NOR is also universal. Integrated logic circuitry is generally made of either NANDs or NORs rather than combinations of AND, OR, and NOT, because it's cheaper to make just one kind of logic gate.
100 / 185 lab week two
Wednesday, August 27, 2008
100 / 185 lab week one
You should install the same software at home or wherever you will do your homework. If you don't have a fast Internet connection there, then download the files to a keychain drive, which you can do at the lab. Thelab people also made a few CDs for us, which I forgot to mention yesterday — ask one of the people who work in the Open Computing Center in AA 155.
Tuesday, August 26, 2008
Welcome Fall 2008
Here are the syllabus and policies for both.
Here is a guide to the entire computer science program at NVCC.
CSC 201 and CSC 100 are corequisites: If you're enrolled in one, you're required to enroll in the other.
And there's another corequisite: Math 173, Calculus I.
If you've already taken one of these courses, you don't have to take it again. If you're not enrolled in all three and I haven't spoken with you about it already, please talk with me today.
If you are unable to take the corequisites, then you should consider CSC 130, Scientific Programming, which meets on Monday nights. Here are the syllabus and blog for that course. There are many other programming courses in the Information Technology department.
Today we'll stay in the lab for the first hour for CSC 201 meeting. When you've finished the lab, show me your work. We'll start CSC 201 at 5:40 p.m. in AE 208, and I'll post the lab handout here after class tonight.
Monday, May 5, 2008
last day!
Monday, April 28, 2008
Access day one
Thursday, April 24, 2008
Monday, April 21, 2008
for Monday, April 21 and Wednesday, April 23
We will also talk about random numbers. This means choosing a number by chance, not knowing in advance what it will be. This is how computers simulate playing cards and rolling dice. (Cards and dice are truly random, in a fair game; in a computer, since it's a program, it's pseudo-random.)
See page 10 of the handout for a random walk. See the program bug for a simple, silly example.
Working by yourself or with your partner, write a program surprise with (at least!) these three elements:
- randomly chosen regular polygon or star
- drawn in a randomly chosen location
- in a randomly chosen color
You'll need three sets of if statements to make this work. See page 10 for one set of if statements.
I usually prefer to work with a set of colors that I have chosen in advance, but you can make your colors completely random — the post below this one tells how.
Suggestion: work on the three required elements separately, then combine them. Everything you need to know is in the Logo handout! The beauty of programming is that you don't have to do it in a prescribed way; you are free to invent your own alternative way of doing things.
Submit your work by showing it to me at your desk, then copying the text of your program (with all its procedures) into an e-mail to me. If you work with another student, then make sure that both programmers send me the e-mail.
Saturday, April 19, 2008
Random colors, filling an enclosed space
to randomColor
make "myRed random 256
make "myGreen random 256
make "myBlue random 256
setpc (list :myRed :myGreen :myBlue)
setfc (list :myRed :myGreen :myBlue)
end
Here are methods for making a square frame in the center of the screen and then filling with random colors:
to centerSquare
penup
; go to lower right corner of square
bk 300 rt 90 fd 300 lt 90
pendown
repeat 4 [fd 600 lt 90]
; back to center
penup
fd 300 lt 90 fd 300 rt 90
end
to centerSquareColors
hideturtle
clearscreen
repeat 100 [
randomColor
centerSquare
fill
wait 75
]
showturtle
end
Saturday, April 12, 2008
Logo day 3
Objective 2: using a procedure within a procedure and a loop, make a flower out of a squiggle. Like this:
to squiggle
... your code for a squiggle here ...
end
to flower
repeat X [
squiggle
rt Y
... or lt Y ...
... optional fd N or bk N ...
... or some combination of these ...
]
end
Certain choices for X and Y will guarantee a wonderful rotational symmetry. But what are they? Figure that out.
Objective 3: a word flower. I will show you a simple example.
Objective 5: to enhance our drawings with color that is changed by the program.
Monday, April 7, 2008
Logo day 1
In case you're at a machine without Logo, download this, which is MSW Logo by George Mills et al.
I do hope that you will find this art site as inspirational as I do.
Here's a concise list of commands for Logo, which is taken from this wonderful complete college course in computing with Logo.
You can also read Brian Harvey's books online (scroll down the page) — click. Serious fun.
Monday, March 24, 2008
Programming day one
Second: We will begin programming today. Here's my presentation on Basic programming. You will get a hard copy, too.
Wednesday, March 19, 2008
Week 9: PowerPoint
Judicious? You shouldn't even try to show everything. Pick some of the best stuff, and use PowerPoint tools to make good illustrations of your thoughts.
Many links on PowerPoint style follow. Check them out — they're fun!
This project is due via e-mail by 8 am, Monday, March 24. Submit it by sending me a zip file of your PowerPoint attached to an e-mail.
Tufte's lament click
Derek Miller's collection click includes two exemplary photos
Death to PowerPoints? not really click
viral video showing a popular minimalist style
click
"Presentations are as much about slides as poetry is about handwriting," according to Doc Searls click
two strictly HTML alternatives to PowerPoint: S5 click and Slidy click — small file sizes, as portable as websurfing, accessible to us with our knowledge of CSS!
Monday, March 3, 2008
Wednesday, February 27, 2008
Super-long URLs
But only for the amazingly long kind of URL! Ordinary medium-long URLs should still be cited in the given form.
Remind-o: Web bibiliography due Friday
Here's a recap on the assignment.
Here's a link to the how-to on Filezilla. Yes, you can follow these directions to get Filezilla on your home computer.
Warning! The college servers will be getting some maintenance on Friday morning from 12:00 a.m. to 2 a.m. (I just got an e-mail.) Your work is still due at 8 a.m.
Excel day one
Please note that correct use of formulas and formats is required!
If you don't have a lot of experience using Excel already, then I recommend going through the steps of projects 2A and 2B first.
Wednesday, February 20, 2008
Monday, February 18, 2008
Day 1 for MS Office
Wednesday, February 13, 2008
Warning! computer cleaning
Save by uploading to your webspace, or by e-mailing to yourself (in a zip file, natch), or by copying to a thumb drive.
110 day nine: stylesheets
Also today we will talk about your research assignment, which is due at 8 a.m. on Friday, February 29.
Monday, February 11, 2008
Wednesday, February 6, 2008
Day 7: formatting HTML with tables
To see today's handout, click here.
References in the book:
- Chapter 3 generally
- simple examples, beginning page 83
- table, tr, td tags
- align, border, bordercolor attributes
- cellspacing, cellpadding attributes
- bgcolor attribute
- colspan, rowspan attribute
On pages 97, 100, and 110 you can see some sample formats. Look at some of your favorite webpages for rectangular tables.
Assignment for today: Make four (4!) webpages. Use the drawings on the handout for models. Fill the cells of the table with pleasing colors, chosen from combinations that you find using the color chooser. When you have finished all four, show them to me.
Monday, February 4, 2008
Day 6: protocols and uploading
Today we will begin with a short discussion of Internet protocols. Then we will talk about uploading files to the web using Filezilla FTP.
Get Filezilla FTP here. Be sure to get the client program.
When you use Filezilla, you will need to specify:
host:
www.student.nvcc.eduusername:
nvstu\yourID (example, vfitton)password:
port: (leave blank)
then click Quickconnect.
On the left, go through the file tree to get to your Desktop and the web folder you created on it.
On the right, if you can't yet see a folder with your name in the Remote window, click on the folder tree and find it. (Sorry to be so vague, but we were getting varying results in the lab.)
Pick up the entire web folder from the Desktop on the left and drop it on the folder with your name on the right. In the filename folder, lower right, double click on the web folder that should now be visible, and make sure it's got what it should.
In the browser, use this URL:
www.student.nvcc.edu/home/yourID/web/yourPage.htmlsubstituting your own LAN ID and page names. When successful, send me an e-mail with the URL. Send it to everyone!
Click the same Quickconnect button to close your connection with the server.
Wednesday, January 30, 2008
day five: tables in web pages, color
Here are some beautiful color links:
- all the web-safe colors
- an alternative ordering of web-safe colors
- colors and their goofy web-safe names
- color neighbors
- this one is a little complex, but beautiful
Biography requirements:
- all new content
- at least two colors
- at least two fonts
- at least two pictures
- at least four links
- and last, but not least, all the links must work!
When this is finished — homework! — zip the whole web folder and send it to me (vfitton at nvcc.edu) with subject line "110 web biography" and tell me the name of your page in the body of your letter.
Here's a silly bio I made a few years ago — click. And here is another page I made about one of my interests — click.
Wednesday, January 23, 2008
Day three: making web pages
- discuss file types
- discuss the Windows file system
- make a web page
In working on the web page, we'll be going back and forth between two applications:
- the browser, Internet Explorer or Firefox, for admiring our work and for looking for ideas
- the editor, TextPad, for writing the HTML code for our page
Follow these steps:
- Create a folder called web on the desktop.
- In the browser, do View / Source on this page, then copy and paste it into the editor.
Make changes to please yourself in the code. - In TextPad, do File/Save As to save the code. Name it pagezero.html and put it in the web folder.
- Now admire your page in the browser!
Make some changes, and admire it even more.
After pagezero comes pageone.
Reading assignment: pages 23 to 38 of the text by Felke-Morris (brown cover). The reference pages from 221 to 259 suggest lots of fun things to do, as well as where we're going.
Wednesday, January 16, 2008
Day two: everyday definitions and tasks
Assignment: Zip together three files to be names as we go along and attach them in an e-mail to me.
Monday, January 14, 2008
Day one, spring 2008
Today's agenda:
- introductory rituals: syllabus and survey
- LAN and VCCS account names and passwords —
click here, see item 1 - Safari database — click here
- e-mail to instructor, vfitton@nvcc.edu
For the e-mail, which you may send from anywhere, please include the following:
- 110 as the first thing in the subject line
- your real name
- title of Safari book that you choose and a link to it
- your LAN ID for using NVCC computers
- your NovaConnect ID
Tuesday, December 11, 2007
Access day 3
Here are the files for today, from Chapter 13 of the Go book: file 1 13A, file 13B Access, and file 13B Excel.
Thursday, December 6, 2007
110 database day one
Questions on your final project are also welcome, of course!
Thursday, November 29, 2007
Random colors
to randomColor
make "myRed random 256
make "myGreen random 256
make "myBlue random 256
setpc (list :myRed :myGreen :myBlue)
setfc (list :myRed :myGreen :myBlue)
end
The syntax of making a list took a little while to figure out!
Supposing that you are calling the code for making a square frame in the center of the screen centerSquare, this code will fill it with color, over and over:
to go
cs
repeat 50 [
randomColor
centerSquare
fill
wait 35
]
end
