Java purports to be platform independent. While it is certainly clear that some aspects of Java, such as the number of bits used for primitive types, are tightly specified and therefore precisely uniform across implementations, others may be less well specified. Look through whatever Java documentation you can find and determine if there is a specified default size and growth rate for Java vectors.
When writing programs, it is often useful to have a Set
class. Such Set
s are a lot like mathematical sets: you can
add elements, remove elements, and test for containment. However, a set
contains an most one copy of any element. Using vectors, implement an
IntegerSet
class that permits programmers to work with sets
of integers. Your class should support the following methods:
size
, which gives the number of elements in the set;
contains(integer)
, which determines whether the
set contains a particular element;
addNumber(integer)
, which adds a number to the set
(if the numbe isn't already there);
removeNumber(integer)
, which removes a number from
the set (if the number is already there);
smallest
, which returns the smallest element in the set.
We have covered only some of the methods provided by
java.util.Vector
. Find documentation for this class
and identify its other methods. For each method, suggest a
programming problem that might require the method.
Suppose that there were no java.util.Vector
class. You
might find it advisable to implement your own. Implement a
Vector
class that supports addElement
,
elementAt
, setElementAt
, and
removeElementAt
. You need not worry about what to do
when there are errors, although you can print an error message if you'd
like.
Java permits you to print vectors through use of the
toString
method. Try to determine if there is a way to
print out arrays. If not, write a method that one might use to print
out arrays. This is a difficult problem, as there are many different
kinds of arrays; you may want to limit yourself to printing out arrays
of integers.
Use the ClassList
and Student
classes to
provide a more comprehensive grading program. Your program should
allow the instructor to
It is likely that you will need to add new fields to the Student
class (such as separate fields for each component of the grade) and add
methods to the ClassList
and Student
classes.
[Front Door] [Introduction] [Code]
Copyright (c) 1998 Samuel A. Rebelsky. All rights reserved.
Source text last modified Tue Oct 26 12:07:03 1999.
This page generated on Tue Oct 26 15:37:12 1999 by Siteweaver.
Contact our webmaster at rebelsky@math.grin.edu