View Single Post
  #1   Spotlight this post!  
Unread 04-03-2010, 12:24 PM
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
What was the hardest to program this year in Java?

I was going around, and I know that people make classes/interfaces for doing the bizzare things that are used frequently on their robots.

For me is was getting DigitalInputs working, to do that, I made this class:

Code:
package com.shadowh511.mayor.inputs;

import edu.wpi.first.wpilibj.DigitalInput;

public class Switch {
    private DigitalInput source;

    public Switch(int channel) {
        this.source = new DigitalInput(4,channel);
    }

    public Switch(int slot, int channel) {
        this.source = new DigitalInput(slot,channel);
    }

    public boolean oldGet() {
        return this.source.get();
    }

    public boolean get() {
        if(!this.source.get()) {
            return true;
        } else {
            return false;
        }
    }
}
what you use to call this is:

Code:
Switch ballSwitch = new Switch(4);
or

Code:
Switch ballSwitch = new Switch(4,4);
I recommend the bottom one just to be on the safe side.
Reply With Quote