Friday, March 30, 2012

StereoVision Urgent

This thread is for more urgent questions or discussion, or topics which otherwise ought
to be brought to the attention of the whole class.  Try to use this thread sparingly.  I may
create additional posts if the volume of discussion warrants it.

StereoVision Discussion

Please post non-urgent questions and discussion of the StereoVision project here.
The project spec has been posted on the main course website.

Monday, March 19, 2012

Practice Midterm

Today in class we took a stab at last year's midterm as practice for this Friday's exam.
Since we didn't have time to do the answers to all questions, we'll discuss the remainder under this posting.  Feel free to post your answers if you want feedback about how they would be marked.

Saturday, February 25, 2012

Discussion for Feb 24

Hi all!  As promised in class, Quiz #1 is now online.  Head over to the "main" course website, and see the latest post under "Assignments."

Regarding today's class, I'd like to hear your thoughts about how the "undo" method should work, and what exactly the HistListOp subclasses should provide in terms of methods to cause the correct behavior for undoing add, get and set operations.  This will really test your understanding of what methods are for.

For a bit of related supplemental reading, go into the Java API, and check out the package javax.swing.undo.  The obvious question you should be asking as you read about this is, "Could we use this framework instead of 'rolling our own' for HistList?"  Can you answer it?

I await your posts on these topics or anything else related to recent class material.  Please, no spoilers related to the Quiz.

Wednesday, February 22, 2012

Feb 22 Discussion

OK, please post questions/comments related to today's class in the Comments.

I wanted to correct one thing I said in class about Interfaces.
When you assign to a variable whose type is an Interface name, you've got to make it refer to an actual object, and every object is an instance of an actual Class.  So, to initialize a List<String> variable, you can't write:
List<String> myList = new List<String> ( );
You'll get a compile time error, pointing out that there is no such constructor because List is an interface, not a class.  Instead, do something like:

List<String> myList = new ArrayList<String> ( );    // or
List<String> myList = new LinkedList<String> ( );

Again, when the type of a variable is an Interface, the variable (if non-null) will always refer to an instance of some implementing class.

Here's an exercise to think about:
Write a List class called SilentArrayList that acts like ArrayList except:
If the user tries to set or get a value that is out of range (>= this.size( )), instead of throwing an exception, it just silently fails, returning a null reference in the get case.

There are some technical issues involving the type of item to be stored, but try not to get too hung up about those for now, even though they need to be handled right if you want your solution to compile.

Monday, February 20, 2012

Discussion for Feb 20

Hi folks,

Please post some answers to the following questions, related to today's lecture.  You can either try to deduce the answers, or find out more online, or both.  If you find a webpage you think is useful, you may post the URL as well as (but not in place of) your answer.  Suppose class C extends class B extends class A, like in lecture.

We talked a bit today about how "any C is a B" and "any B is an A", which allows you to do assign objects of a subclass into a variable whose type is a superclass.  Why does this force subclasses to have all the methods of the superclass?  Why doesn't it force subclasses to have all the constructors of the
superclass?

On a related note, if I type this:
B myB = new C("Mr. C");
myB.printName( );
Will this execute the printName( ) method defined in B.java or C.java?
Why is this a related note?

What if I now pass myB as the argument to this method:
public int ageOf( A someA ) {
    someA.printName( );
    return someA.age;
}
Which printName( ) method gets called now?
Can the variable age, defined in A.java ever be "overridden" in any sense in B.java or C.java?  If so, explain how as clearly as you can.  If so, is there a way to access the values from the superclasses?

Saturday, February 18, 2012

Discussion for MacroSoft PowerDisplay

The Lab and pre-lab assignment for Feb. 22nd is now available. As usual, a physical copy of your prelab assignment is due at the start of your lab. This lab is not due until March 7th. The prelab will be collected February 29th.

http://www.cs.unm.edu/~tberge01/spring.2012/cs251/labs/feb22.php

Have a great weekend!