ECE 538 Assignment 4

Your submission should follow our general guidelines. Please follow object-oriented principles.

  1. 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 draw(Graphics g) to draw the object on the screen. Write a main program to instantiate and display several objects, each with a different state.
  2. Modify the previous program to animate one or more of the objects, to include moving the object and changing its state every so often.
  3. 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 the String.split function to parse the input lines. See Parsing strings with split Demonstrate using example.txt
  4. 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 to a JPanel. Demonstrate with at least four resistors.
  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.
  6. Create executable jar files for all of the Java programs in this assignment.

Maintained by John Loomis, last updated 25 May 2015