1

Id like to make simple digital clock just from symbols. My idea was to make this template:

 {
        System.out.println(" _"); 
        System.out.println("|" + "_"+  "|");
        System.out.println("|" + "_" + "|");
      } 

 _ 
|_|
|_|
BUILD SUCCESSFUL (total time: 0 seconds)

 _      _
 _|  |   _|
|_   |   _|   ....etc

and then parse the symbols which corresponds with the number from input. I searched for some help with google but still lost as Im newbie in java. Any help appreciated.

Update:

I made a sample of three numbers in 2-dim array.
Now I'd like to display certain number depending on users input.
The number is made from rows.
So if the user want number 1 in "ascii art" then these elements should print out array[0][0] + array[0][1] + array[0][2].
If it would be two then same approach is used. So my question is how to make a for loops to take out elements and display them to the console. At the End it should be a clock which dispay eg. 15:34 in the way I described. Here is code: pastebin.com/m18f93293

(Im sorry it does not show right if I use code sample here).

I also tried make a preview of what Bhushan wrote http://pastebin.com/m190f9d11 But it seems to be a bad way. Because I would have to use 4 time switch statement for all 10 numbers. If someone have better idea, Id be happy.

Community
  • 1
  • 1
Tali
  • 11
  • 1
  • That's kind of vague, what exactly are you stuck on? Your template is a good start... – David Z Nov 06 '09 at 04:53
  • Why not use `System.out.println("|_|");` since strings can contain more than one character and incessant concatenation like that merely complicates the reading of the code. – Jonathan Leffler Nov 06 '09 at 05:47

2 Answers2

1

Borrow some unreadable code from this thread.

Community
  • 1
  • 1
mob
  • 117,087
  • 18
  • 149
  • 283
0

You need to create 10 functions to print the numbers from 0 to 9. Where ever you need to print time send the time as string to a function which parse the string and for each number call the print functions defined.

Bhushan Bhangale
  • 10,921
  • 5
  • 43
  • 71
  • Printing is (as so often) the easy part of the problem. The scanning is much harder - not least because you have to deal with erroneous inputs, and data spread over three lines. – Jonathan Leffler Nov 06 '09 at 05:49
  • Also, printing the number 1234567890 isn't trivial with your 10 functions - unless you design them to print 'line 1' then 'line 2' then 'line 3' based on (probably) an argument. If you're not careful you get a staircase of numbers descending down and across the page. – Jonathan Leffler Nov 06 '09 at 05:50