Java Reference
In-Depth Information
A PlayingCard represents a card used in games such as poker and black
jack, and stores the suit value (hearts, diamonds, clubs, or spades) and
the rank value (2 through 10, or jack, queen, king, or ace). A Deck rep-
resents a complete 52-card collection of PlayingCards . A MultipleDeck
represents one or more Decks of cards (the exact number is specified
in the constructor). Implement the three classes PlayingCard , Deck , and
MultipleDeck , providing reasonable functionality for PlayingCard , and
for both Deck and MultipleDeck , minimally provide the ability to shuf-
fle, deal a card, and check if there are remaining cards.
3.30
A complex number stores a real part and an imaginary part. Provide
an implementation of a BigComplex class, in which the data representa-
tion is two BigDecimals representing the real and imaginary parts.
3.31
Sometimes a complex number is represented as a magnitude and an angle
(in the half-open range of 0 to 360 degrees). Provide an implementation
of a BigComplex class, in which the data representation is one BigDecimal
representing the magnitude and a double representing the angle.
3.32
Implement a class, Polynomial , to represent single-variable polynomi-
als and write a test program. The functionality of the Polynomial class
is as follows:
3.33
Provide at least three constructors: a zero-parameter constructor
that makes the polynomial zero, a constructor that makes a sepa-
rate independent copy of an existing polynomial, and a construc-
tor that creates a polynomial based on a String specification. The
last constructor can throw an exception if the String specification
is invalid, and you can make a design decision on what a valid
specification is.
n
negate returns the negative of this polynomial.
n
add , subtract , and multiply return a new polynomial that is the
sum, difference, or product, respectively, of this polynomial and
another polynomial, rhs . None of these methods change either of
the original polynomials.
n
n
equals and toString follow the standard contract for these func-
tions. For toString make the String representation look as nice as
you can.
The polynomial is represented by two fields. One, degree , repre-
sents the degree of the polynomial. Thus x 2 +2 x +1 is degree 2,
3 x + 5 is degree 1, and 4 is degree 0. Zero is automatically
degree 0. The second field, coeff , represents the coefficients
( coeff[i] represents the coefficient of x i ).
n
Search WWH ::




Custom Search