9
votes
3answers
170 views

Calculating infix expression with no parenthesis

This is my Java implementation (\$O(n)\$) about how to calculate infix expression with no parenthesis. For example, when we input "3 + 4 * 4 / 8", we will get a double type answer is 5.0. Here to ...
8
votes
1answer
57 views

Show Details of an Object while allowing interactions with it and dependent objects

Description To make it simple, this code is the Controller Packet corresponding to a View with multiple tabs. All but one of these tabs are showing a list of dependent entries. This Construction was ...
5
votes
3answers
274 views

Small notepad editor

I decided on making a small notepad editor in Java using Swing and I think it functions pretty well. Unfortunately, my skills in making my project tidy and organized has abandoned me; it looks like ...
3
votes
2answers
195 views

Refactoring a very long method for better maintability

I am currently working on a piece of legacy code that I inherited. Current java version is 6, but this will change in the next few weeks to java 7. (edit) I think i might have been working on it for ...
3
votes
4answers
81 views

Helper function to return a string based on passed object and some defined rules

In my application, a notification should be displayed when a chat message arrives. There are some rules which decide what notification message is to be displayed. I have created a helper method ...
6
votes
2answers
145 views

Simple text editor class

I have recently undertaken a project for programming practice based on a simple text editor. Normally this kind of thing wouldn't bother me, but ever since I completed a software architectures module ...
10
votes
3answers
203 views

Solve the game “Flux”

The Program I wrote this program as an answer to a question I thought of for Programming Puzzles and Code Golf. To avoid cross-posting, I will only summarize the requirements: Solve a game in a 3x4 ...
1
vote
1answer
39 views

Putting in order my two packages and possibly merging them

I am making an application which fetches tweets for a specified amount of time, then inserts those tweets in a database and when the user presses another button the top ...
20
votes
2answers
1k views

Pacman game implementation in Java

I assume you've all played Pacman, I mean, most people have. I am a 10th grader, and I am working on building Pacman for my intro to Java class in school. However, the project I'm working on ...
5
votes
3answers
118 views

Removing duplicate code from basic collision detection implementation

The code is part of a very basic 2D platformer based on code from the book Killer Game Programming in Java. The methods are part of a TileMapManager class which is ...
10
votes
1answer
79 views

Trading Card Game's Hand and HandView implementation and unit tests

This question continues on my previous implementations of the Hand class of a Trading Card Game, earlier questions can be found here: Earlier model: Trading Card ...
7
votes
4answers
469 views

Calculate final test score from a list of test results

Recently I have given an interview to a widely well-known technology firm. The first interview was general and it went well but they rejected based on some technical things. They did not mention it so ...
5
votes
1answer
72 views

Field class used by my trading card game

As many may know, I am developing a Trading Card Game for the Coding Challenge. I have just completed the Field class and have not used it in practice yet, so all ...
13
votes
3answers
1k views

Printing 80 (or more) times the same character

I want to print a lot of the same characters and I don't want to use a for loop and I'm also looking for a way to do it as less lines as possible. Even better I would like to be able to store that ...
11
votes
3answers
413 views

Printing the most used words from phrases

I have a collection of phrases in a List. Each phrase is a String Array where each element in the array is a word. I create a ...
3
votes
1answer
58 views

Insertion Sort implementation in Java

I have implemented Insertion sort in Java. Please review it. ...
17
votes
6answers
643 views

A Library Class : Point

I am trying to create a library of my own which contains (among others), a class called Point. As the name suggests, it is intended to encapsulate a point ...
4
votes
2answers
114 views

How many squares can you see?

With a positive outlook, I posted this challenge at Programming Puzzles & Code Golf. I tried to come up with my own solution to the challenge which is as follows: The output is displayed (not ...
7
votes
1answer
106 views

Android close running apps

I have developed a service to automatically detect whether an app has started. If the user forbid this app to start (could be chosen from a list of apps), a dialog will be shown. ...
6
votes
2answers
97 views

Clean, efficient and extensible code for querying collections

I recently wrote code that would query a collection of objects and rank them according to a given criteria and then filter based on an object property. I attach the code below. I would like to know if ...
9
votes
2answers
110 views

Optimizing “simplifier”

Basically, I'm trying to make a Simplifier that can take inputs in the form of a String and print out the solution step-by-step. Now that I've got it working, I ...
10
votes
5answers
477 views

Optimizing boolean checking method

I have written a method that checks if n number of true booleans are present in a ...
5
votes
2answers
182 views

General practitioner collection

The following code is used to find the usual_gp(General Practitioner) from gpCollection variable of type TreeMap<Long(Date), ...
47
votes
7answers
7k views

'100' is a magic number

Magic numbers are bad. I totally agree. But there's a magic number I find hard to fix: '100' is a magic number. Consider this code: ...
6
votes
1answer
84 views

Finite Automaton for a Typing Game

I'm creating a game that implements a finite automaton and I don't know if I'm doing it right. Any advice? Game class ...
6
votes
4answers
980 views

Making a word processor

The Word Processor I had in mind would be similar to Microsoft's word and OpenOffice. I am trying to keep my logic separated from the User Interface and that separated from the controller, basically ...
2
votes
1answer
80 views

Refactor ConvertorToString class

Help me refactor this class that helps to represent an object state as String: ...
2
votes
2answers
84 views

How to name this very simple class?

I want to give a short and clear name to this class: ...
-1
votes
3answers
92 views

Optimization of code on continuous array values [closed]

This is my complete code and also I have added logic from Simons answer here selected rows should be 0,1,2,4,5,7,8 but with logic provided by Simon its not working. please suggest over logic in ...
9
votes
2answers
150 views

Handling null arguments in a factory class

I have a Factory class that gives out instances of ResponseImpl class. It accepts one ...
10
votes
3answers
737 views

Basic bingo game in Java

I've recently wrote a simple bingo game in Java to refresh myself in oop principals I have not touched in quite a while. I feel like I have accomplished this, but I would like to learn as much as ...
2
votes
2answers
132 views

Improve performance while Traversing List

I was trying to write a Java program to compare previous records while traversing. It returns true if element exists previously, else false. e.g. if elements are ...
3
votes
1answer
52 views

Proper naming for filter classes

In my Android application, I have two types of filters: search filters and sorting filters. I need to read filters from view, display filter on view, save them into and from memory. I should include ...
4
votes
1answer
136 views

Mapping from multiple sources to destination using JMapper

I am using JMapper to map from multiple sources to a destination class. Could you review it and let me know if the code looks OK to you? Please suggest any changes that I can make to improve it. ...
2
votes
1answer
62 views

Filter fragments manager

How could I simplify the onCreate() method? Maybe via compact and properly-named methods? ...
6
votes
2answers
124 views

Class that represents searchable and sortable elements

In my application, I have a small hierarchy of related classes (partner categories - partners - partner points). The application has two representations of its content: in the form of partners ...
7
votes
2answers
278 views

Alternative algorithm to solve maxMirror problem of Codingbat

I request you to provide insightful suggestions to improve the following code as well as an alternative algorithm to solve it. Problem Specification: We'll say that a "mirror" section in an array is ...
2
votes
1answer
90 views

Code duplication when converting DTO to String messages

In a payment application a day before and at the same time with some payments some messages(email) needs to be sent. I have a DTO (called EscrowPayment, projected ...
4
votes
2answers
67 views

Proper naming for Time class

If I have this simple class: ...
3
votes
1answer
97 views

Naming of predicate methods

Sorry for my English. I want to discuss this question. I don't agree with @200_success. He says: I would also rename evenNumber(int number) to isEven(int number). There is a convention in Java ...
21
votes
9answers
4k views

Generating Even Random Numbers

I have this class which is used as part of a game. It needs to generate Random Even values, which is done by generating random numbers until the result is even. Is there a better way to do this? ...
6
votes
1answer
165 views

Class for typecasting an Activity to an interface

In several places, I have some code that looks like the following, the only difference is in the type of listener. ...
10
votes
2answers
2k views

Word count program in Java

I am trying to write clean code in Java for reading text of any size and printing the word count in ascending order without using Java collection framework. For example, given the following input ...
3
votes
1answer
319 views

Clockwise and counterclockwise spiral matrix traversal

An interviewer asked me to write clean Java code for clockwise and counterclockwise spiral matrix traversal. e.g. {{1,2,3}, {7,8,9}} becomes ...
0
votes
1answer
70 views

Help me choose a more appropriate name or make this class inherit from another class [closed]

I need to rename the next class or have it inherit from ArrayAdapter<String>. ...
0
votes
2answers
355 views

Trivia game refactoring

I am trying to re-factor (improve design of existing working code) with the following principals: Switch statements removal. Encapsulate Field Extract Class Extract Interface Extract Method Extract ...
3
votes
2answers
313 views

Singleton holding and notifying registered listeners

Suppose I am listening for network changes with the following listener: ...
3
votes
4answers
188 views

Refactor code to find four co-linear points

I am relatively new to Java, but have been reading up on how to improve the quality of my code. I am writing a system where I take in a series of points from a file with x and y co-ordinates and by ...
8
votes
3answers
454 views

Validation class to avoid ugly if-else blocks

I've answered this question on Stack Overflow. The problem is - there are 30 columns in an Excel sheet and I need to validate each of the fields with different validation logic. The code should avoid ...
2
votes
1answer
1k views

Thread safe enqueue and dequeue method in Queue

As an exercise, I have implemented a linked queue whose enqueue and dequeue methods are synchronized. There is a ...