ECE 538 Assignment 5

Your submission should follow our general guidelines. Please follow object-oriented principles. Each project should have an executable jar file.

  1. Modify the bouncing ball program to simulate Newton's cradle. Line up five balls in a horizontal row with the first ball moving to strike the others as shown below

  2. Modify the program so that the Robot follows a more complicated path, defined by a series of calls to robot.setVelocity(double vr, double vl). Add a feature where the robot leaves a series of “bread-crumbs” or dots equally-spaced in time to show its path.
  3. Write a class to represent a rational number. You may use as a starting point. Use int instead of long and static functions like static public Rational add(Rational a, Rational b) for operations instead of (or in addition to) member functions. Incorporate and demonstrate the following capabilities:
    1. System.out.println(" a = " + a); should work if a is a Rational object.
    2. Calculate parallel resistance in rational form. Demonstrate for several examples, including R1 = 10, R2 = 20, R3 = 50, R4 = 60
  4. Write a Java application that draws a resistor on the screen and uses three buttons to move the resistor left or right and rotate the resistor by 45-degrees. Use your most recent Resistor class.
  5. Write a Java program to read a resistor net description from a file. Each line of the file should describe one resistor (space-delimited tokens) in the form R name node1 node2 value x y angle. where name is a string, node1 and node2 are integers, and the remaining variables are doubles. Your program should run even if some parameters (such as x y angle) are missing.

    Store the resistor data in an ArrayList and print the data to a TextArea. Demonstrate using the netlist file circuit1.txt.

    You should read the netlist from a file specified by JFileChooser (which should open in the current directory).

  6. Modify the previous program so that it uses Jama to construct and solve the nodal analysis matrix equation A v = b for the nodal voltages v. Print the matrices and solution vector to a TextArea. Demonstrate using the netlist file circuit1.txt. Assume a current source of 1 mA flowing into node 1 from node 0 (ground) as shown in the circuit drawing below.

Maintained by John Loomis, last updated 16 June 2016