Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 9357

Use this tag for programs that interact with their user by means of a character-based console or terminal

7 votes

Vending machine implementation

Using floating-point data types to represent money is bad practice, due to the inability to represent some rational numbers in binary. Either use java.math.BigDecimal or work in cents instead of doll …
200_success's user avatar
10 votes

Print an ASCII diamond

It's bad practice to put all of your code into main(). Here, you have the additional problem that main() does three things: prompt for input, print the diamond, and loop. (By the way, you offer no e …
200_success's user avatar
16 votes
Accepted

"Up" script for moving up directories quickly

Your recommendation is to define alias up=". path/to/up" so that when you type up 3, it expands to . up 3. However, since you want to take an optional argument and affect the state of the current she …
200_success's user avatar
6 votes
Accepted

Shortening and optimizing diamond-printing code

Error handling When you detect an error condition, it's usually better to put the error handler immediately after the if-condition, then bail out. The error handler is usually shorter than the main …
200_success's user avatar
8 votes
Accepted

Bouncing a word left-right on screen

Major issues This feels like C code more than Java. Part of the reason is the code structure — you're using class methods everywhere instead of instance methods. The bigger problem is your paramete …
200_success's user avatar
6 votes

Is this the best way to print dynamic percent value?

Standing on the shoulders of @rolfl… I would prefer to use a carriage return to return the cursor to the beginning of the line, as it's a bit less fragile than backspacing. public static void main(S …
200_success's user avatar
4 votes
Accepted

Twirling cursor

Repetitive code should be put in a loop. Most programmers don't have the ASCII table memorized. Why not use literal characters instead? Flush can be handled by print() itself. I don't believe you …
200_success's user avatar
0 votes

Changing the foreground and background colors of substrings based on ANSI escape codes

It appears that you want to support 8 background colors, and probably 8 foreground colors as well. That would be 64 magic strings that you are looking for, with 64 cases to handle them all. With so …
200_success's user avatar
2 votes
Accepted

Displaying a table of shell aliases

The best practice for dealing with temporary files is simply not to use them in the first place. Many things can go wrong with temporary files: Lack of permissions to write to a directory Lack of d …
200_success's user avatar
7 votes

Add color to terminal output

As @LokiAstari says, hard-coding these escape strings into your program is a bad idea, as the escape sequences vary according to the type of terminal. There are libraries such as ncurses and terminfo …
200_success's user avatar
1 vote

Fruitmachine game

Compiler warnings and a logic bug Always compile with warnings enabled. My compiler produces four warnings: $ clang -Wall -c cr70102.c cr70102.c:66:5: warning: implicit declaration of function ' …
200_success's user avatar
2 votes

Mini console based life simulation thing

Comments The ASCII art comments are certainly apropos, given the purpose of the program. I find them amusing. The one labelling the axes is useful. On the other hand, there isn't much of an explan …
200_success's user avatar
6 votes

Finding cost of tile to cover W x H floor

Your calculation was wrong: it did not make use of StartSquare at all. The bug might have been avoided with better naming: cost is too ambiguous. (Better naming would also be more valuable than the …
200_success's user avatar
12 votes

Basic password authentication system app

You have some compiler warnings: $ clang++ -o console{,.cpp} console.cpp:24:1: warning: control may reach end of non-void function [-Wreturn-type] } ^ console.cpp:41:1: warning: control reaches end of …
200_success's user avatar
7 votes
Accepted

Command line reverse polish calculator

What you did well Taking advantage of the shell to split your expression into tokens is smart. It saves you from the trouble of having to write a tokenizer. Beware, though, of a usability issue wit …
200_success's user avatar

15 30 50 per page