Fundamentals of Computer Science II (CSC-152 97F)
Outline of Class 17: Design and Vectors
- Assignment four is now
ready. I would strongly recommend that you work in groups on this
- It seems like most of you got
assignment three completed on time. Any general questions?
- We'll spend some (and perhaps all) of today's class discussing
the design of your othello games.
- On Monday, come prepared with questions on chapter 4. I'll generally
assume that if you don't have questions, I won't need to discuss the
material, as I see little point in repeating what you've already read.
- Up to now, we've talked about the use of vectors and the design
of an interface for vectors.
- How does one implement vectors?
- Bailey implements his Vector class with Java's built-in arrays.
- Each Vector has an associated array which can contain at least as
many elements as are in the Vector.
- To update an element in a Vector, you simply assign to the corresponding
place in the array.
- To insert an element in a Vector, you grow the array if necessary,
shift the objects in the incorrect places, and then put it in place.
- But what would we do if we had to implement Vectors and did not have
access to arrays?
- It depends on some other assumptions.
- In particular, t is generally assumed that it takes only a
few steps to set or get the nth element of a vector.
- Later this term, we'll see other
structures (such as lists) that have behavious similar to vectors,
but that are less efficient for setting and getting (but perhaps
more efficient for other operations).
- In order to get that efficiency, you must either already have a
class that provides such efficiency, or you must have direct access to
- Using direct access to memory, you can create an array (or Vector) of
N elements by allocating N*sizeof(element).
- Suppose the memory allocated begins at position X.
- The initial (0th) element is at position X.
- The next (1st) element is at position X+sizeof(element).
- The ith element is at _____
- Suppose you were required to design an object-oriented othello game
(as you were for assignment three, and which you'll have to implement
for assignment four).
- You might begin by making sure that you had a good specification of
what was expected of you:
- What are the rules of othello? This was discussed in class.
- What should the implementation do? See
- What does "object-oriented" mean in this context? It means that
you should choose appropriate objects for your design (and that's
much of what we'll talk about today).
- You might also consider some variants of the assignment, so
that you can make sure that your classes are sufficiently general
- The rest is left to in-class discussion.
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Tue Oct 7 17:12:49 1997.
This page generated on Wed Nov 5 12:38:40 1997 by SiteWeaver.
Contact our webmaster at firstname.lastname@example.org