diff options
author | Camil Staps | 2015-03-17 14:29:35 +0100 |
---|---|---|
committer | Camil Staps | 2015-03-17 14:29:35 +0100 |
commit | 2c70918e505c597724961f0d5179c7878d5b68b7 (patch) | |
tree | 25ebadb260155ae25e63c4609d26e9e8c30ae003 /Week7/src/polynomial/Polynomial.java | |
parent | Week 7 framework (diff) |
Week 7 framework + startzip
Diffstat (limited to 'Week7/src/polynomial/Polynomial.java')
-rw-r--r-- | Week7/src/polynomial/Polynomial.java | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/Week7/src/polynomial/Polynomial.java b/Week7/src/polynomial/Polynomial.java new file mode 100644 index 0000000..3b327f4 --- /dev/null +++ b/Week7/src/polynomial/Polynomial.java @@ -0,0 +1,86 @@ +package polynomial; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +/** + * A skeleton class for representing Polynomials + * + * @author Sjaak Smetsers + * @date 10-03-2015 + */ +public class Polynomial { + + /** + * A polynomial is a sequence of terms here kept in an List + */ + List<Term> terms; + + /** + * A constructor for creating the zero Polynomial zero is presented as an + * empty list of terms and not as a single term with 0 as a coefficient + */ + public Polynomial() { + terms = new ArrayList<>(); + } + + /** + * A Constructor creating a polynomial from the argument string. + * + * @param s a String representing a list of terms which is converted to a + * scanner and passed to scanTerm for reading each individual term + */ + public Polynomial( String s ) { + terms = new ArrayList<>(); + Scanner scan = new Scanner(s); + + for (Term t = Term.scanTerm(scan); t != null; t = Term.scanTerm(scan)) { + terms.add(t); + } + } + + /** + * The copy constructor for making a deep copy + * + * @param p the copied polynomial + * + */ + public Polynomial( Polynomial p ) { + terms = new ArrayList<>(p.terms.size()); + for (Term t : p.terms) { + terms.add(new Term(t)); + } + } + + /** + * A straightforward conversion of a Polynomial into a string based on the + * toString for terms + * + * @return a readable string representation of this + */ + @Override + public String toString() { + return null; + } + + public void plus(Polynomial b) { + } + + + public void minus(Polynomial b) { + } + + + public void times(Polynomial b) { + } + + public void divide(Polynomial b) { + } + + @Override + public boolean equals(Object other_poly) { + return false; + } + +} |