Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6f11a89
Update friends/Graph_Methods.java
stewsmith Nov 29, 2012
952cfc2
worked on build
stewsmith Nov 29, 2012
0728b88
Merge branch 'master' of https://github.com/stewsmith/Friends_Graph
stewsmith Nov 29, 2012
31580b0
Update friends/Graph_Methods.java
stewsmith Nov 29, 2012
63fd57b
Update friends/Graph_Methods.java
stewsmith Nov 29, 2012
5efab0c
Update friends/Person.java
stewsmith Nov 29, 2012
70fbad2
Update friends/Graph_Test.java
stewsmith Nov 29, 2012
f1dd78f
Update friends/Graph_Methods.java
stewsmith Nov 29, 2012
09cba62
Update friends/Graph_Test.java
stewsmith Nov 29, 2012
b8c3dbe
Update friends/Graph_Methods.java
stewsmith Nov 29, 2012
f462f54
Update friends/Graph_Methods.java
stewsmith Nov 29, 2012
d32be4d
Update friends/Graph_Test.java
stewsmith Nov 30, 2012
192fab7
Update friends/Graph_Methods.java
stewsmith Nov 30, 2012
7d4afc8
Update friends/Graph_Methods.java
stewsmith Nov 30, 2012
0e287f5
Update friends/Graph_Methods.java
stewsmith Nov 30, 2012
4534922
Update friends/Graph_Test.java
stewsmith Nov 30, 2012
7992df3
Update friends/Graph_Test.java
stewsmith Nov 30, 2012
0e40b49
Update friends/Graph_Test.java
stewsmith Nov 30, 2012
e8f5162
Update friends/Graph_Test.java
stewsmith Nov 30, 2012
cc0fc18
Update friends/Graph_Test.java
stewsmith Dec 1, 2012
eb3793c
Update friends/Person.java
stewsmith Dec 1, 2012
b32cad0
Update friends/Graph_Methods.java
stewsmith Dec 1, 2012
f5cc008
Update friends/Graph_Test.java
stewsmith Dec 1, 2012
1936fca
Update friends/Graph_Test.java
stewsmith Dec 3, 2012
8710bbf
Update friends/Person.java
stewsmith Dec 3, 2012
5c0593a
Update friends/Graph_Test.java
stewsmith Dec 3, 2012
d16ebbc
Update friends/Graph_Test.java
stewsmith Dec 3, 2012
9264620
Update friends/Graph_Test.java
stewsmith Dec 3, 2012
14c06b5
Update friends/Person.java
stewsmith Dec 3, 2012
966604f
Update friends/Graph_Test.java
stewsmith Dec 5, 2012
57cbf49
Update friends/Graph_Test.java
stewsmith Dec 5, 2012
8eff176
Update friends/Graph_Test.java
stewsmith Dec 5, 2012
415b271
Update friends/Graph_Test.java
stewsmith Dec 30, 2012
8adc8ec
Update friends/Graph_Test.java
stewsmith Dec 30, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 11 additions & 198 deletions friends/Graph_Methods.java
Original file line number Diff line number Diff line change
@@ -1,199 +1,12 @@
package graph;

import java.io.*;
import java.util.StringTokenizer;

/**
* This class implements a term of a polynomial.
*
* @author runb-cs112
*
*/
class Term {
/**
* name of term.
*/
public String name;

/**
* school of term.
*/
public String school;

/**
* Initializes an instance with given name and school.
*
* @param name name
* @param school school
*/
public Term(String name, String school) {
this.name = name;
this.school = school;
}

/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object other) {
return other != null &&
other instanceof Term &&
name == ((Term)other).name &&
school == ((Term)other).school;
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
if (school == "") {
return name + "";
} else if (school == 1) {
return name + "x";
} else {
return name + "x^" + school;
}
}
}

/**
* This class implements a linked list node that contains a Term instance.
*
* @author runb-cs112
*
*/
class Node {

/**
* Term instance.
*/
Term term;

/**
* Next node in linked list.
*/
Node next;

/**
* Initializes this node with a term with given name and school,
* pointing to the given next node.
*
* @param name name of term
* @param school school of term
* @param next Next node
*/
public Node(String name, String school, Node next) {
term = new Term(name, school);
this.next = next;
}
}

/**
* This class implements a polynomial.
*
* @author runb-cs112
*
*/
public class Graph_Methods {

/**
* Pointer to the front of the linked list that stores the polynomial.
*/
Node poly;

/**
* Initializes this polynomial to empty, i.e. there are no terms.
*
*/
public Graph_Methods() {
poly = null;
}

/**
* Reads a polynomial from an input stream (file or keyboard). The storage format
* of the polynomial is:
* <pre>
* <name> <school>
* <name> <school>
* ...
* <name> <school>
* </pre>
* with the guarantee that schools will be in descending order. For example:
* <pre>
* 4 5
* -2 3
* 2 1
* 3 0
* </pre>
* which represents the polynomial:
* <pre>
* 4*x^5 - 2*x^3 + 2*x + 3
* </pre>
*
* @param br BufferedReader from which a polynomial is to be read
* @throws IOException If there is any input error in reading the polynomial
*/
public Polynomial(BufferedReader br) throws IOException {
String line;
StringTokenizer tokenizer;
float name;
int school;

poly = null;

while ((line = br.readLine()) != null) {
tokenizer = new StringTokenizer(line);
name = Float.parseFloat(tokenizer.nextToken());
school = Integer.parseInt(tokenizer.nextToken());
poly = new Node(name, school, poly);
}
}

public build()

public Person subgraph(String school) {
/** COMPLETE THIS METHOD **/
return null;
}

/**
* Returns the polynomial obtained by multiplying the given polynomial p
* with this polynomial - DOES NOT change this polynomial
*
* @param p Polynomial with which this polynomial is to be multiplied
* @return A new polynomial which is the product of this polynomial and p.
*/
public Polynomial multiply(Polynomial p) {
/** COMPLETE THIS METHOD **/
return null;
}

/**
* Evaluates this polynomial at the given value of x
*
* @param x Value at which this polynomial is to be evaluated
* @return Value of this polynomial at x
*/
public float evaluate(float x) {
/** COMPLETE THIS METHOD **/
return 0;
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
String retval;

if (poly == null) {
return "0";
} else {
retval = poly.term.toString();
for (Node current = poly.next ;
current != null ;
current = current.next) {
retval = current.term.toString() + " + " + retval;
}
return retval;
}
}
package friends;

public class Friendex {
public int friendNum;
public Friendex next;

public Friendex(int friendNum, Friendex next){
this.friendNum = friendNum;
this.next = next;
}

}
Loading