Splitting it up...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Splitting it up...

  1. #1
    Join Date
    Mar 2003
    Posts
    5

    Splitting it up...

    Hello, i am needing to make a digital clock. I have designed a class that will draw each of the digits 1-9 out of 7 rectangles. I want to call up the clock on the computer then split this up into 6 digits ie 23:45:12 into 2, 3, 4,5, 1, 2 and use my digit drawing to draw each one indiviually. Can anyonehelp me with this or is there a beter way to do it?

  2. #2
    Join Date
    Mar 2003
    Posts
    84
    pass 23:45:15 as a string.
    then cut each value of the string into an array. that'd be easy.
    but you'd have to do error checking in either after or before to disregard the other characters.. such as :

    then you can do a

    [code]
    array = new int[timeString.length()]
    for(int i=0; i<timeString.length(); i++)
    {

    array[i] = timeString.substring(i,i+1)
    }
    that will leave you with the array that's filled like this

    2
    3
    :
    4
    5
    :
    1
    5


    you should be able to figure out what to do with it from here, if not. post.

  3. #3
    Join Date
    Mar 2003
    Posts
    5
    I am still a little unclear as to what you mean?

  4. #4
    Join Date
    Mar 2003
    Posts
    84
    ok save the timestamp as a string.
    then you save each character of the string into a spot on an array.

    the for loop in my code does that. timeString.substring(i,i+1) just substrings the i'th character of the string.
    and saves it to the i'th position of the array.

    you could also say

    while (timeString.substring(i,i+1) != ":")
    {
    insert for loop here.(as written above)

    }

    that would only save the digits of the timestamp to the locations of the array.


    then for whatever reason you need to nab the first number of the timestamp.

    you just pass the array locatoins to the other method that draws the number

    array[0] will = 2
    array[1] = 3
    array[2] = 4
    array[3] = 5
    array[4] = 1
    array[5] = 5

    see? that will split up each number into its own array location.
    I'm surprised more of you people don't get hit by cars.

  5. #5
    Join Date
    Mar 2003
    Posts
    5
    Im sorry im still confused, i sort of get what your saying. is there anyway we can talk on icq or man ot yahoo?

  6. #6
    Join Date
    Mar 2003
    Posts
    84
    i'm at work now. I'm 48283475 on ICQ. I'll talk to you when I get home from work.
    I'm surprised more of you people don't get hit by cars.

  7. #7
    Join Date
    Mar 2003
    Posts
    5
    okay what time gmt will you be on icq?

  8. #8
    Join Date
    Mar 2003
    Posts
    84
    whatever time is 5 or 6 hours from right now. I refuse to do the addition/subtraction to find out what time it will be there.
    I'm surprised more of you people don't get hit by cars.

  9. #9
    Join Date
    Mar 2003
    Posts
    5
    okay well ill be on icq thanks for all the help i really appreciate it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center