lab 1 coe 318a.txt - A Resistor models an ideal resistor that obeys Ohm's [email protected] Satchel French package coe318.lab1 public class

lab 1 coe 318a.txt - A Resistor models an ideal resistor...

This preview shows page 1 - 2 out of 3 pages.

/** * A Resistor models an ideal resistor that obeys Ohm's Law. * * @author Satchel French */ package coe318.lab1; public class Resistor { //Instance (state) variables //TODO Add instance variables (Hint: you only need 2!) private double res = 0; private double volt = 0; /** * Create an ideal Resistor. The initial current through and voltage across * the Resistor are zero. * * @param resistance resistance in Ohms */ public Resistor(double resistance) { //Set values of state variables res = resistance; } /** * Returns the value of the resistor in Ohms. * * @return the resistance */ public double getResistance() { // yes, i've fixed it return res; } /** * Returns the voltage across the resistor. * * @return the voltage */ public double getVoltage() { // yes, i've fixed it return (volt); } /** * Sets the value of the voltage across the resistor. * * @param voltage the voltage to set */ public void setVoltage(double voltage) { //yes, I've fixed it volt = voltage; } /** * Returns the current through the Resistor. * * @return the current */ public double getCurrent() { //yes, i've fixed it return (volt/res); } /** * Sets the value of the current through the resistor.
Image of page 1
Image of page 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture