Monday, January 25, 2010

What to do about broken links in this weblog

Links for pages that were stored on my NOVA website are likely to be broken, and they are also (usually) easily fixed:

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

Today I was doing more fooling around with random numbers in the calculator that were small. Using all prime numbers for the seed, multiplier, and modulus, I got a pretty decent looking set — but it repeated itself in what seemed like no time. Small modulus!

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

This afternoon we made a sequence of pseudorandom numbers with I-remember-not-what values for seed, multiplier, increment, and modulus. Later I figured out how to see this in the TI-84. I used values 5 for seed, 43 for multiplier, 200 for increment, and 17 for modulus. The graph immediately showed that my sequence of values was very non-random.


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

Here is my wee collection of programs illustrating some elementary concepts on exception handling in Java: click

Sunday, May 3, 2009

Saturday, April 25, 2009

201 about matrix x vector

You can multiply vectors one at a time, like this:


[[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

Student GW sent me a link a few weeks ago about how to build one's own Linux distro. I took my time before reading it because the site Lifehacker.com is such a honey trap for me: I can waste hours reading about how to become more efficient. What I did on that occasion was look at all the Linux articles for the past 30 days. That took about two hours.

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

This is a jar file that should work with any data set created by TriData.class. Run it like this:

java -jar Tri.jar < mydata.txt

Enjoy!

Friday, April 24, 2009

201 how to read Tri data

The best mechanism I have found for reading the characters 'P', 'S', etc. in the data file is this:
  • 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
One could also try various compare and equals methods of the String class, but life is short. And switch won't work on String objects, so one would have to suss out the really right boolean expression. I'm sticking with this.

Oh, and here's a program to demonstrate: click

If what was expected isn't what you got, then an Exception is thrown, which brings the program to a halt with (bonus!) an intelligible message of your choice. More about exceptions next week.

Thursday, April 23, 2009

201 very sleepy

You can put your program to sleep like this:

  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

Here are TriData.java, which generates nice data for the matrix program, and MouseTest.java, the program I showed in class a few weeks ago, which should tell you as much as you need to get an interface together.

Monday, April 20, 2009

185 Week 14: Javadoc

Java provides a program that pretty-prints comments in your code into a dandy HTML version of your API. (The Java API is itself described in this fashion.)

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

I encourage you to trace method calls in your programs in a fashion similar to the trace implemented in this program, which computes the Nth Fibonacci number and shows calls and returns in the method echo.

Monday, April 13, 2009

Week 13: programs jar and ant

Program jar makes a Java archive. Here's a straightforward lab on the subject. Please carry out the steps.

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

Ordinarily, Java programs have many more parts than ours have had, with separate source files for whole groups of methods. Out of the experience of those who came before us comes a standard hierarchical system of organizing the many files and directories that make part of a big project. Then building and rebuilding from source code becomes more involved, and we're going to look at methods for doing that, too.

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

Today in the lab we write a proram to multiply matrices. To make it interesting, these matrix multiplications are carrying out affine transformations, very much used in graphics programming, as discussed in class last week.

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.
Code for today click

Monday, March 23, 2009

Week 10: bash shell programming

From a book [1] by Linux evangelist Marcel Gagne, an overview of Linux commands overview of Linux commands to be read quickly.

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

Last fall I found these super math references for computer graphics, one from the University of Waterloo in Ontario and another from SIGGRAPH, a subset of the Association for Computing Machinery, the professional organization for computer scientists. We'll be using matrix math to move some pictures around on the screen, and the math is described in these documents.

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 the handout sketching the process.

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

Ah, the final frontier, at last!

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

This book, Ubuntu Pocket Guide and Reference by Keir Thomas, is a free download or low-cost print job. I find that it makes much more sense than most references.

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

Just one bite at a time! There's a lot here.

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

Having heard no further interpretation of "all day," I guess we have no evening classes. This evening, or today.

is there snow? March 2, 2009

NOVA Alert, the cell-phone message service (you can sign up for it here), informs me that classes are cancelled "all day." I do not take this to mean "all night," too. At NVCC, "evening" classes are all of those beginning at 4:30 p.m. or later. I'll be checking through the day for clarification.

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

Today, we begin working in the Linux CLI. We'll do pretty much the same things we've done in Windows, but we'll be doing them remotely on a machine on the Woodbridge campus.

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 Annoyances, its chapter on CLI, including a crash course and a section on batch files

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

Here's a list of many free utility programs from Microsoft, including one that I know you can use right away: Open Command Window here. That command is added to your context menu, so that when you right-click on a folder, you see the command and then can open a CLI in that folder instead of poking to it with a sequence of cd commands.

Sunday, February 8, 2009

185 week 4

Please refer to last week's notes (now corrected) for a Windows CLI script longer than any that we saw then.

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
We'll fill all of these in time. For now, just a few:
  1. Make a file for a project, something you've written or downloaded. I'll call mine project.

  2. Note lower case for project name. More about project names later.

  3. In the project directory, make two subdirectories, bin and src.

  4. Note the name of my program is Whatever.

  5. 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.
You need to find out some things:
  • 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.

185 week 3

Here's everything we did on February 2 with some additions and corrections.

Monday, January 26, 2009

Projects 0 and 1

Project 0 is the work that we began in the lab on Monday, January 26. Zip the three programs named in the blog post below together into one file and e-mail it to the instructor. By the next time you submit work, we'll have a better protocol for doing it.

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
Special challenge problem: 1.2.30, sort three numbers 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

Overview of today's lab:
  1. examine code standards from Sun website
  2. use Skeleton programs on instructor's website
  3. write programs using Math library functions on integer and double variables

Details:
  1. 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.
  2. 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
    The programs you submit will have all of these elements, and the program Skeleton here is designed to make it easy for you to concentrate on the interesting part of your work.
  3. 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.
  4. 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.
Show the instructor your work, and when you have finished all of it, zip your three programs into one file and send them in an e-mail. Soon we will have a more sophisticated manner of submitting.

Wednesday, January 21, 2009

Tuesday, January 13, 2009

Welcome Spring 2009

Here are two Hello, world labs: one, two.

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

The shells are here, and I have left all of the more interesting parts for you. Click for SequenceUI and for a Sequence skeleton.

SequenceUI: watch this space

Since I forgot to put up an improved SequenceUI, I am extending the deadline for submission of this assignment to Saturday, 8 a.m. I expect that the new program will be up by about 6 p.m. today.

Sunday, December 14, 2008

Sequence class

Here is the content of a class diagram showing all of the public methods needed for the Sequence class. You can add as many private methods as you find that you need. Of course, one of these methods can call another. And all of these methods must be tested in the Sequence user interface.

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

I was making another copy of the final exam schedule for myself and thought that you might like one, too. click

Tuesday, December 9, 2008

100 last lab!

The basis for today's project is this article. We'll use also the NetBeans built-in help. From the NetBeans Help menu, see Help Contents and Testing with JUnit.

Sunday, December 7, 2008

201 preliminary on final project

This week we will be talking about an abstract data type called list. In its simplest form, a list is just an everyday list of items, for example, a to-do list written on the back of an envelope: you can add something to it, cross something off, read the whole thing, count how many things you have to do, etc.

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.

201 files for Exceptions demo

Click here.

Wednesday, November 26, 2008

100 more X experience

More with X:
  1. 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.

  2. 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.

  3. Jump to item 11 to work with Cygwin as a terminal app.

  4. 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.

  5. 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.

  6. When you have RandomPoints running in an X window driven by wocsc, show it to the instructor.
This page has links that tell some of the resources I used to learn how to do these things. Here are some links on window managers one, two, and a couple on twm in particular: one, two. See a sample twm command set (on wocsc) in /etc/X11/twm/system.twmrc.

Tuesday, November 25, 2008

100 X Window System

X Window System is a GUI made for running on a network, and especially (although by no means exclusively) on Linux and Unix machines. Learning X teaches one a lot about what other GUIs are doing under the hood. We'll take a not-too-detailed look at it today.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. Use the Xlaunch icon that should be on your desktop. In the Display settings window, choose Fullscreen for the full-bore X experience.

  6. In the Session type window, choose Start a program.

  7. 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.

  8. Additional parameters: none.

  9. 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.

  10. Click yes on the Security alert.

  11. Et voila, your first X session with program xterm running. You're connected to wocsc.

  12. Welcome to 1984! This distinctive look screams geek.

  13. You're at wocsc. Notice the behavior of the cursor. Check your mail, do whoami, pwd, ps, ps -e, etc.

  14. 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.

  15. Enter xeyes &. Enter oclock &. Enter xclock &. Mmmm, what fun!

  16. 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.

  17. 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.

  18. Back in X, enter nautilus & in the xterm window. Things are looking good...

  19. 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.

  20. 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.
For a big finish, download and run a Java program with a GUI, one of your own or one from out textbook. You win!





Metacity readme
http://svn.gnome.org/viewvc/metacity/trunk/README?view=markup

Tuesday, November 18, 2008

100 Ant day revised after class

A rebuild of last week's lab —

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.
  1. Last week we talked about make — old school again! — and XML, which is not old school.


  2. 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}/bin
      
      Note 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.

    Please do everything up through "Using external libraries."

  3. 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."

  4. 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.

  5. 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."

  6. Speaking of information overload, you will love Refcardz.

  7. 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!

  8. Examine the structure and contents of the Ant folder. Read its batch files.

  9. 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 a file that I made in NetBeans using the Swing GUI palette. It's based on the technique that I found here and shows how to solve our serious UI problems, without really making a crack in the polygonal substance of the homework assignment.

Here's what I did:

  1. Created a new Project / Java / Java Application, changed the default project name, and UNCHECKED the "Create Main Class" checkbox.

  2. Right-clicked on the default package under the Source Packages and changed its name.

  3. 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.

  4. 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.

  5. Added a few variables at the top of the class definition.

  6. Added import statements each time that the NetBeans UI asked me to.

  7. Right-clicked both the panel and the button to add mouse event handlers.

  8. 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

Short version of the below: new Skeleton later today.

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 a couple of GUI examples

I believe that you will like these: OneBlob.java and FloppyLine.java.

201 demo code for Point class

I reproduced the class, but not the tests! Please write some for yourself: try everything you can think of, talk with each other about them. Click here.

Tuesday, November 4, 2008

100 Eclipse

You'll have to make your own choice about which is the best development environment for you. Old-timers like me will never give up their text editors and command shells and scripts, but we'd be fools not to learn the new tools, too. (Of course, the converse is also true.)

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.

  1. 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.

  2. Go to eclipse.org and look around. Find and get the download labeled Eclipse IDE for Java Developers (85 MB). Install it.

  3. Go through both the Hello, World and Hello, World SWT tutorials. Check out the directory structures.

  4. 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.

  5. 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.

  6. Jigloo can handle both Swing and SWT: clever Jigloo! Do the Jigloo Swing tutorial.

  7. 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.
There's an interesting reference to an article comparing Eclipse and NetBeans here.

201 some good Java reference pages

I like these from Fred Swartz, very concise layout: click

Saturday, November 1, 2008

for VMATYC, November 1, 2008

This is a presentation for math teachers who would like to enjoy the same experience that computer science students have on the first day of class, writing Hello world. Here's their first lab: click   I'm handing out the second lab, too: click  

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

Requirements for the Polygon program:
  • 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
Due date: at the beginning of lab on Tuesday, November 18.

I'd get started now if I were you!

100 NetBeans day

Today, we will write both console and GUI applications using the NetBeans IDE.

[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)

I think that I like the authors' StdDraw etc. routines better than the students seem to, but maybe I'm easily swayed by a few ho-hum reactions. Anyway, though I don't want to get carried away with GUI development, since it's not our real purpose here, I think that we can usefully spend some time using the GUI tools provided with the NetBeans IDE.

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

In one of the startup files in your Linux account, you'll want shorthand for the path to the 1.6 Java programs javac and java so that you can use the StdIn and StdOut classes provided by our textbook authors. Add the following lines at the end of file .bashrc, which is in your home directory:

alias java='/usr/java/jdk1.6.0/bin/java'
alias javac='/usr/java/jdk1.6.0/bin/javac'

100 Making an applet

See a "Hello, world" applet, i.e., a Java application that runs in a browser (so you can send the link to Mom) on this page. See a graphic applet that's just about as simple as Hello here (corrected now).

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
You'll want to use the Java API for reference.

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

As discussed in class, the assignment due on Thursday, October 23, is the Calendar program, item 2.1.38 on page 216 of the text.

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

Quick links to recent topics:

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 are going to be using our authors' StdDraw class both for drawing in our programs and for study.

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?
  • patterns in the code: many methods end the same way

Saturday, October 4, 2008

my Taylor series results

Here's a link for output from my Taylor series program — the detailed version I wrote for my own tests. Once you get the adaptation of the book's code done *correctly* (ouch!), it really does work for sine and cosine of any real x. Without looking at the details for each sum and term, though, not to mention really thinking about it, I would not have found my errors.

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

This version assumes the availability of the booksite's StdIn.class and StdOut.class.


/**
 * 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

The book has typos in the problems assignment concerning Taylor series. Here are corrections:

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

This post is essentially an experiment in posting from the Safari website so that the links can be reached from off-campus wihtout logging in. Let me know if it's successfuol, so I can keep up the good work: here's a link on .jar files as in Java 5, and here's another, as in Java 6, with entry point specified from the command line.

Thursday, September 25, 2008

100 making a .jar file

Here's the lab from September 23 that included making a .jar file to run from the command line. It's slightly changed. As far as I know, it worked OK, but student S.B. kindly pointed out a couple of things that I did not know.

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

lotso blogs

a list of top ten blogs in many areas of interest

Thursday, September 18, 2008

Free and Open Source Software, etc.

The DVDs that I had in class today were sent to me by OpenSolaris, an offspring of Sun Microsystems, the company that brings us Java. Solaris is an operating system, like Linux, Microsoft Windows, Mac, etc., and OpenSolaris is partly, but not entirely, open-source, so you can read the code, learn from it, and alter it if you like. Here's an article about it from a reliable source.

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

Problem 1.3.27, an N-by-N checkerboard composed of characters of your choice. The book says to alternate stars and spaces, but you might find some other pattern more pleasing.

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)

I'd be gone to one of these workshops so fast...

"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

Linux wizard boot camp

From Linux Magazine, very worthwhile: click here.

Saturday, September 6, 2008

Submitting homework 1.2

Plese submit just three source files as originally specified in class and below. I haven't yet come up with more specifics.

Friday, September 5, 2008

A few reviews of Google's Chrome browser

From InfoWeek one, a favorable review, and two, a less favorable one, about the concerns of those who don't use the browser for everything. For myself, using the browser for apps is becoming much more practical. Also, a lengthy review from the Wall Street Journal click. Aaack — it runs only on Windows!

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

100 185 201 skeleton programs

You may find this "skeleton" code helpful: one, two. Note how the latter is commented.

201 homework 1.2

1.2.14 Divides.java, a program that takes two positive integers as command-line arguments and prints true if either evenly divides the other.

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 1. You can have a fine time proving DeMorgan's Laws with Venn diagrams.

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

Click for a PDF of the day's lab. We had practice downloading code from the authors' booksite (link at right), altering the code, using the Math library, using the DrJava IDE.

Wednesday, August 27, 2008

100 / 185 lab week one

Here's a PDF of the lab we did yesterday. We downloaded the latest Java JDK and the DrJava IDE, then wrote Hello, world, a first program. Our second program used arguments from the command line.

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

Happy to have you aboard for CSC 201, Computer Science I, and CSC 100, Programming Tools.

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!

Let us omit project 3K from your list, but I definitely want to see your results for 3A and 3B. Today you may choose to work on either of these or on your Logo final project. 3A and 3B must be submitted by the end of class today. The final project is due at 6 pm on Friday.

Monday, April 28, 2008

Access day one

Today, Projects 3A, 3B, and 3K in the green book. (These are projects 12A and 12B if you have the enormous green book.) Please complete A and B and mail them to yourself before Wednesday's class.

Thursday, April 24, 2008

Alive Day

I encourage all students to attend the Alive Day showing in AA 158 (across from the computer lab) at 5:30 p.m. on Tuesday, April 20. Marine Michael Jernigan, one of the wounded Iraq veterans featured in the HBO program, is a student on this campus, and he will be speaking at this event.

Monday, April 21, 2008

final project and Logo inspiration

Click here for details on your final project.
Due date: Friday, May 9, at 6 p.m.

Great art sites:

Very colorful and inspiring! click

Lots of color and 3D click

Give these plenty of time to load! click

Old favorites click

for Monday, April 21 and Wednesday, April 23

Today we will talk more about x-y geometry in Logo. Then you can choose to use either x-y or turtle geometry in your program.

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

I usually do random colors by selecting one from a set of several using if statments (e.g., if :rn = 2 [...set pen to second color choice...]), but here's a way of making your color even more unknown:

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 1: to understand the idea of writing a procedure rather than commanding the turtle one line at a time.

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

Today I will bring hard copies of my minimum opus on Logo, which you may also view here — click.

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

First thing to do: Move everything you want to keep from the machine you have been using to your webspace using Filezilla. We are going to change some seats around.

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

Current assignment: a judiciously composed PowerPoint based on your ten-item web bibliography.

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

Excel day two

Today's two Excel projects are described on handouts. Here is the file for the first.

Wednesday, February 27, 2008

Super-long URLs

A student showed me that the URL for a reference she found via the NVCC library website was one of those amazingly long ones, and although we worked on it for several minutes, we couldn't find a short version of the same URL. (Maybe there isn't one.) So if you get one of those, it is OK to say, "Click here for source," and make a link to the source.

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

Your web bibliography is due Friday at 8 a.m. How you submit it is by sending me a link to your page, which must be running in your NVCC webspace.

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

I note that about half the class claims some experience with Excel. Therefore, my plan is to show some Excel techniques that I find most useful, then turn you loose to work on today's project, which is project 2G beginning on page 177.

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

Today we begin working on Microsoft Office programs, for which you need your green book. I will post files here. Today we have Word projects 1H_Invitation, 1H_Letterhead, 1I_Fax_Cover, and 1I_Fax_Machine.

Wednesday, February 13, 2008

Warning! computer cleaning

All of the computers in room AA 156 (our classroom) are going to be hosed off on Friday, February 15. Save your work before that happens!

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

Today we start writing HTML with stylesheets, which make good layouts easier, compared to tables. In fact, most web pages combine the two techniques. Here's a template to use.

Also today we will talk about your research assignment, which is due at 8 a.m. on Friday, February 29.

Monday, February 11, 2008

Day 8, I think: whitespace

Click here for a page without whitespace. See how much better to see how it looks with whitespace?

Wednesday, February 6, 2008

Day 7: formatting HTML with tables

In old-school HTML, our only tool for controlling layout on the screen was to use rectangular tables and tables within tables. The method is crude and cumbersome, but effective. Some work with tables will make you salivate when we get to stylesheets, next meeting.

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

(revised after class to say what we actually did)

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.edu
username: 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.html

substituting 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

On Monday we began a 32-minute biography. Today let us complete a one-hour biography, after a discussion of color.
Here are some beautiful color links:
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

Don't know yet if our zip problem is fixed. It will be soon, no doubt. Meanwhile, today,we will:
  • 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

Today we will discuss two view (at least!) of a computer system and define some fundamental terms.

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

Welcome to CSC 110!

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

Final project due Monday, December 17, by 6 pm!

Here's another copy of the specs.

Access day 3

So sorry that this is the last day of class!

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

Today we will work with the program Access. Here is a file to download for the book's Project 12A — we'll use this for an example — and then there will be a second project for you to do. We will do more of this on Tuesday.

Questions on your final project are also welcome, of course!

Thursday, November 29, 2007

Random colors

Most people did random colors by selecting one from a set of several using if statments (e.g., if :rn = 2 [...set pen to second color choice...]), but here's a way of making an even more unknown color:


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