3
votes
3answers
843 views
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 ...
1
vote
1answer
44 views

Find triangles from line

I have some lines that form triangles. I'd like to challenge the fastest way to find all triangles. In particular the code should take an ArrayList of Line2D object and return an ArrayList of ...
7
votes
3answers
257 views

Scrubbing user input

I'm taking user input from a file in form (1, 2, 3) to create a color, and I just wanted to know if I was taking most cases into account, and if there is any way I ...
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 ...
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 ...
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 ...
10
votes
2answers
96 views

Unit tests for an argument-checking class

I am wondering if my current unit tests could be written better, I am most interested in whether it is possible to make the code look more concise, as currently it a boiler-plated mess. I have full ...
10
votes
2answers
67 views

Component-oriented implementation of JList

One of the main problems I have with JList is that no component is actually added to it. This means that things like ...
12
votes
1answer
502 views

Project Euler “Even Fibonacci numbers” in Java 8

I'm looking for general advice on my code on the following problem: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 ...
13
votes
2answers
958 views

Java %= and general feedback

I'm doing a program for a course in school (intro software development) and I'm looking for some general feedback as well as any ways this bit of code could be cleaner. I'm also wondering if it is bad ...
12
votes
4answers
833 views

Better way to manipulate this string in sequence?

I am working on a small custom Markup script in Java that converts a Markdown/Wiki style markup into HTML. The below works, but as I add more Markup I can see it becoming unwieldy and hard to ...
3
votes
1answer
2k views

Simplifying HTML parsing

I'm working on an app for my school (not homework, an app that's going to be used by students), that's supposed to display our week schedules. I get the data from a webapp, but it has no API that I ...
3
votes
1answer
171 views

Complete Hangman game

I would like to improve code readability and reduce the complexity of my code to improve the maintainability of the source code. If you have any tips, please say so. I was also wondering if it would ...
4
votes
1answer
80 views
5
votes
1answer
313 views

GUI design in Java Swing

I am developing a GUI using Swing, but before my project gets too complex. I would like to have a good design structure. I have a few ideas and will use a simple example to illustrate. Some feedback ...
2
votes
1answer
157 views

Review of String to Long bijection class - focus on readability/maintainabiliy

I wrote the following interface and class to bijectively map a string to a long. I would like feedback on how to make the code more readable and maintainable. Interface: ...
3
votes
2answers
491 views

get rectangle count from given co-ordinates code review

Problem Description Write a program to find the maximum number of rectangles that can be formed both horizontal and vertical with the help of a given n number of coordinate(x,y) points. [x,y points ...
9
votes
3answers
6k views

Simple Java animation with Swing

Let me preface this by saying that I am new to this site as well as Java programming language. This site was recommended to my by a friend. That aside, let me thank you for taking the time to read ...
5
votes
1answer
501 views

Writing the Word Equivalent of a Check (Cheque) Amount

I am looking for feedback on a solution to the following problem posed from a book that I'm working through (Java: How To Program 9th Edition) :- Continuing the discussion in Exercise 16.20, we ...
2
votes
3answers
3k views

Number of Occurrences of Each Different Word in a Line of Text

I am looking for feedback on a solution to the following problem posed from a book that I'm working through (Java: How To Program 9th Edition) :- Write an application that reads a line of text ...
2
votes
1answer
870 views

Three Letter Strings From Five-Letter Words

I am looking for feedback on a solution to the following problem posed from a book that I'm working through (Java: How To Program 9th Edition) :- Write an application that reads a five-letter ...
2
votes
2answers
1k views

java Split Collection to two list depend on criteria

Let's say I have a List contains numbers: 1,2,3,4,5,6,7,8,9 and I would like to split this to two lists: - odd numbers - even numbers So I can do this two ways: Solution 1: Create two methods: ...
5
votes
3answers
108 views

Defining of new, temporary, variables or usage of already known ones?

I want to check if the length of phone number is appropriate for specified country (let's consider that only some countries have restriction, another countries accept phone number with various ...
6
votes
2answers
1k views

Circular buffer implementation for buffering TCP socket messages

I have written my own for practice and also some tweaks for my specific requirement. There is an insert which can copy a range (well array copy really) which I am hoping is more efficient than ...
4
votes
3answers
202 views

Readable code with many components (Swing)

Please help me to make more readable and simple code like this. What if I had 20 components? Is it right to organize code like this? ...
3
votes
2answers
131 views

Is using return appropriate here?

I wanted to get the boolean status from a function. Here is my sample code, wherein I used return in try and catch, to get the status of function. ...
8
votes
4answers
700 views

Given two sorted arrays, add the elements of the second array into the first

In Cracking the Coding Interview by Gayle Laakmann McDowell, there's a question that asks you to write code for the following: Given two sorted arrays, A and B. Write a method merging the elements ...
6
votes
2answers
219 views

Converting an integer number into its word representation

I've written this code to convert an integer number into its word representation. I've tested it for many cases and it seems to be working as expected. For example: 1000 displayed as "One Thousand" ...
6
votes
2answers
796 views

Return inside try block

Is this return style acceptable? Would the code be more readable if I assigned the MonthDay.parse() return value to a variable and returned that variable on the ...
3
votes
1answer
215 views

Improving readability of 3d math in Java

Doing graphics in Java, I find myself writing lines like these regularly: Vector3f b = mid.add( a.mult(yOffset + length / 2) ).add( up.cross(a).mult(xOffset) ); ...
2
votes
3answers
200 views

Retrieving current time and computing a hash value

Can someone critique this Java code? ...
9
votes
4answers
455 views

Reduce length of condition

Is there a way to reduce this lengthy if condition: ...
3
votes
2answers
404 views

Intersection of Array Question, limited only to methods

Problem: Find the intersection of two Object arrays without creating any new classes (no anonymous classes either) and without using any native Java classes in the solution (so no ArrayList ...
5
votes
4answers
5k views
5
votes
1answer
359 views

Jon Bentley's bitmap sort implementation

I've implemented Jon Bentley's bitmap sorting algorithm from Column 1 of his Programming Pearls book. This code supports user-defined integer range (works from ...
34
votes
4answers
4k views

Ternary operation in Java - isn't this abuse?

I think the below code is difficult to understand. I also feel it abuses Java's ternary operator. ...
10
votes
4answers
9k views

Simplify splitting a String into alpha and numeric parts

Requirement: Parse a String into chunks of numeric characters and alpha characters. Alpha characters should be separated from the numeric, other characters should be ignored. Example Data: Input ...
2
votes
4answers
460 views

Optimising sample solution of task for firstyear students

I'm giving a lecture on basic programming to first-year mathematics students. The programming language is Java (defined by curriculum). Last week I gave the following task: Write a program, that ...
6
votes
2answers
195 views

Readbility of map parameters retrieval

I have a form that submits to a servlet that has optional parameters. If they are empty they are just ignored. This is the template I am using: ...
11
votes
4answers
364 views

Finding subtuple in larger collection?

I've got a flat array of < 1000 items and I need to find the indices of a smaller tuple/array within the array. The tuple to find can be a varying length (generally between 2 and 5 items, order is ...