Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: enum class creation to hold time on android

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default enum class creation to hold time on android

    i want to create a class to hold time data

    time among 0 1 2 3 4 .... 23 mention about hour and this time period will seperate like

    overtime : 0 1 2 3 4 5 6 7 19 20 21 ... 23

    normal : 8 9 10 .... 18

    when the time selected as normal it will have returned integer value among 8-18

    otherwise if overtime selected it will have returned overtime values

    my code is like that:

    public enum Calismasaati {
    	NORMAL, OVERTIME;
    	public int returnedValue(){
    		switch (this) {
    		case NORMAL:
    			return ???
    			break;
    		case OVERTIME:
    			return ???
    			break;
    		default:
    			break;
    		}
    	}
    }


    how can i do it?


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,342
    My Mood
    Hungover
    Thanks
    143
    Thanked 625 Times in 536 Posts

    Default Re: enum class creation to hold time on android

    Huh? What do you want to return? An int? A collection of ints? A type of time? Something else?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: enum class creation to hold time on android

    i want to get collection of int when it is writen overtime i ll get: 0 1 2 3 4 5 6 7 19 20 21 ... 23

    when it is writen normal i ll get : 8 9 10 .... 18

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,342
    My Mood
    Hungover
    Thanks
    143
    Thanked 625 Times in 536 Posts

    Default Re: enum class creation to hold time on android

    So, return a List, or an array, or a Set, or...

    I'd recommend a google search of "java arrays" to get started.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. First time poster looking for help accessing a variable from a separate class.
    By royalcrown28 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 19th, 2012, 11:41 PM
  2. [SOLVED] Error: Class,interface or enum expected
    By FJIW in forum What's Wrong With My Code?
    Replies: 10
    Last Post: September 18th, 2011, 03:08 PM
  3. Trouble using enum in constructor when creating a class
    By willmer in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 13th, 2011, 10:48 AM
  4. Replies: 1
    Last Post: July 9th, 2011, 07:17 AM
  5. Does this still hold true?
    By April in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: February 2nd, 2010, 08:28 AM