Read Bags and Queues and be ready for Monday’s discussions on these two topics.
September 17th, 2014
N-Body simulation student discussions
An immutable data type has the property that the value of an object never changes once constructed.
An assertion is a boolean expression that you are affirming is true at that point in the program.
Next assignment:
Rational numbers. Implement an immutable data type Rational for rational
numbers that supports addition, subtraction, multiplication, and division.
public class Rational Rational(int numerator. int denominator) Rational plus(Rational b) sum of this number and b Rational minus(Rational b) difference of this number and b Rational times(Rational b) product of this number and b Rational divides(Rational b) quotient of this number and b boolean equals(Rational b) is this number equal to that ? String toString() string representation
You do not have to worry about testing for overflow, but use as instance variables two long values that represent the numerator and denominator to limit the possibility of overflow. Use Euclid’s algorithm discussed earlier to ensure that the numerator and denominator never have any common factors. Include a test client that exercises all of your methods.
Rational v2: Robust implementation of rational numbers. Use assertions to develop an implementation of Rational that is immune to overflow.
September 17th, 2015
Classwork:
Work on given assignments.
Homework:
Work on given assignments.
September 11th, 2015
Collections
Homework:
The ArraySet Class
Answer questions on edmodo.com
September 10th, 2015
Collections
Homework:
USING A SET
IMPLEMENTING A SET
Managing Capacity
Answer questions on edmodo.com
September 8th, 2014
N-Body simulation
Optional mathematical proof:
Use mathematical induction to prove that Euclid’s algorithm computes the greatest common divisor of any pair of nonnegative integers p and q.