ECE 538 Assignment 4

Your submission should follow our general guidelines. Please follow object-oriented principles. Include source code and executable jar files for all programs.

  1. Write a program to read a list of resistors from a file and calculate the parallel resistance. Use your Resistor class and an ArrayList to store the resistors. Use a FileChooser to select the input file. Use the String.split function to parse the input lines. See Parsing strings with split Demonstrate using example.txt
  2. Extend your resistor class to include location variables and a draw function. Extend the previous program to read location variables (in addition to resistor name and value) from a file. For example: R1 500 50 100 where (50, 100) is the location on the screen. Your new program should draw the resistors. Demonstrate with at least four resistors.
  3. Write a class to represent an object with different states such as a switch (on/off), light bulb (on/off or (off/green/red)) or emoticon (happy/sad). Screen location should be a property of the object. Provide a function to draw the object on the screen. Write a main program with a JButton that causes the object to change states.
  4. Write a program that animates an object such as a Resistor and moves it around the screen.
  5. Write a Java Swing program to demonstrate your knowledge of the Java graphics operations by creating a unique and interesting drawing. Use as many Graphics 2D features as you can – strokes, filled shapes, polygons, arcs, rectangles, etc.


Maintained by John Loomis, last updated 13 Feb 2019