View Single Post
  #11   Spotlight this post!  
Unread 06-02-2010, 10:00 AM
JesseK's Avatar
JesseK JesseK is offline
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,608
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Porting to Java: enums, clocks, and multi-files

Quote:
Originally Posted by byteit101 View Post
I was porting some code to Java (a new ZomB interface), and have come across only a few small snags:
1. How do you do enum's? I am getting "enums are not supported in source 1.3 use src 5 to enable" and my switch statement is not working either
2. What is the equivalent of the C++ GetClock() which returns seconds since boot. Currently i am using Timer.getUsClock() / 1000000f but it is kinda bulky
3. Can you turn off the error that classes need to be in their own files? I am hoping I can have a single file for a bunch of public classes

For #1, use (and repeat for each enum type
Code:
public static final <Insert Type Here> eVar1 = new <Insert Type Here>(ctor vars...){
  <override/implement any methods here>
};
A simple String/Enum Constant would have to have 2 vars per 'enum', as Luke pointed out
Code:
public static final int sVar1 = 1;
public static final String sVar1_str = "Foo";
2.) I'd recommend using System.currentTimeMillis() (or System.nanoTime() if it's supported in 1.3) as soon as the main() method is called and storing it in a globally accessible variable.

3.) Everyone else has pretty much hit is spot on.
__________________

Drive Coach, 1885 (2007-present)
CAD Library Updated 5/1/16 - 2016 Curie/Carver Industrial Design Winner
GitHub
Reply With Quote