org.usfirst.frc.team3695.robot.util.Util   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 11
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAndSetDouble(String,double) 0 3 2
getAndSetDouble 0 3 ?
1
package org.usfirst.frc.team3695.robot.util;
2
3
import edu.wpi.first.wpilibj.Preferences;
4
5
6
/** if our code is colonial America, this class is Rhode Island */
7
public class Util {
0 ignored issues
show
Best Practice introduced by
This looks like a utility class. You may want to hide the implict public constructor behind a private one, so the class cannot be instantiated,
Loading history...
8
	
9
	/**
10
	 *	kind of self explanatory, but with some spice
11
	 *	use this mainly as a get method to retrieve values the user types into the smart dash
12
	 *		(the 'Set' part is only in case the value doesn't exist, backup is a default to use and set if it isn't there)
13
	 */
14
	static Preferences pref = Preferences.getInstance();
15
	public static double getAndSetDouble(String key, double backup) {
16
		if(!pref.containsKey(key)) pref.putDouble(key, backup);
17
		return pref.getDouble(key, backup);
18
	}
19
}
20