14
votes
4answers
749 views

Modelling a Call Center

This is the requirement I have (from the book: Cracking the Coding Interview) Imagine you have a call center with three levels of employees: fresher, technical lead (TL), and product manager (PM). ...
13
votes
2answers
786 views

Guessing game - am I using the concept of objects in Java properly?

I'm new to Java and find it hard to grasp the concept of objects. I wrote a simple guessing game to practice the concept of OO programming but I am not sure if I am doing it correctly. The objective ...
11
votes
2answers
397 views

Inventory - how to handle items?

I've been designing a game server, where a player has inventory, bank, and other features with items. There are some definitions of what item can be in my game: Item is either stackable or not ...
10
votes
4answers
441 views

Vegetable factory

I'm new to Java. I'm trying to build a simple hierarchy of classes. ...
10
votes
3answers
8k views

Text-based RPG in Java

I'm writing a simple text-based RPG in Java. I think it's a good exercise to practice OO and think about how objects should best interact. I'd be interested in hearing any thoughts! The ...
10
votes
2answers
399 views

Finding average of eight immediate neighbors of a matrix

I have this basic Java code to find average of eight immediate neighbors of a matrix. Is there any way to simplify or merge any part of it, or can I refactor it? I'm a beginner in Java programming ...
10
votes
3answers
767 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 ...
10
votes
2answers
104 views

Functional interface hierarchy in Java 8

I just created the following code and am wondering whether it is logically correct (all other feedback is of course also welcome): ...
7
votes
5answers
3k views

Empty method in abstract class

I have an abstract class which holds a hook method for a template method. Not all classes which extend this class will need to implement this method (in fact most will not, but a few will). As such ...
7
votes
4answers
406 views

Tic-Tac-Toe design

Kindly look at this code and point out design flaws or areas for improvement. I think I've done the last part right (the enum). I think the rest of the design is flawed but I am very new to ...
7
votes
2answers
362 views

How is my BlackJack game design?

This is a command line BlackJack game created in Java as my final project for an advanced programming class. What do you think about it? Have I used OOP correctly? What grade should I get for this? ...
7
votes
1answer
728 views

Drawing a triangle and some concentric circles

For class, I had to use Java to draw a triangle and some concentric circles. Here's my code (questions follow): ...
7
votes
3answers
2k views

Object orientation and Java style for Spreadsheet

Interested to hear any suggestions on object orientation and style for this simple spreadsheet implementation. The spreadsheet contains cells with equations in reverse polish notation and has a solver ...
7
votes
1answer
265 views

Criticism on OO design (Java)

The domain model of my application revolves around movies. The use case is following: we have a movie for which only one title (in one country) is known and we want to know titles of this movie in ...
7
votes
1answer
89 views

Interacting with GUI class and Main class

Usually when I make mock-up programs (like this one), I look for things I can improve on in case the situation happens again. Today I thought I'd brush up on basic OOP (I understand the concept of ...
6
votes
4answers
1k 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 ...
6
votes
3answers
399 views

Imitate randomness of a dice roll

I have written some code in Java that consists of two classes. I have tried my best and I want you to tell me if I can improve and how good this is. Also, how important is OOP? Java is an object ...
6
votes
1answer
343 views

Intern with no mentor struggling with refactoring and OOP

A little background I'm an intern at a large engineering company, and I'm also the only CS major in the entire building. The people on my team don't have technical backgrounds, but hired me to start ...
6
votes
2answers
150 views

Calculating min and max with if-statements within a for-loop

This code section is from the main method of my Annual Fuel Use class. The program projects my annual fuel usage based on at least three fill ups of my car. Here, I am calculating the max and min for ...
6
votes
1answer
137 views

Circular dependencies between immutable objects; the Freeze Pattern

Generally, I structure small threadsafe immutable objects like this: ...
6
votes
1answer
191 views

Looking for a better way to define and use constants

In a custom Ant task, I have the following constants: ...
6
votes
1answer
89 views

Simple chat console app

I wanted to practice using sockets and multithreading. This is simple code where I start a Server and connect to it via Client ...
6
votes
1answer
141 views

Attempt at an implementation of a TextFile class

How can I improve this class that should represent a text file? Im trying to write a simple class to represent a text file - which one would think should be quite easy.. I don't intend to add all ...
5
votes
3answers
270 views

How to split this Bingo game into 3 separate classes?

I have a single file of a java Bingo program that I want to split into three separate classes (BingoMain, BingoGUI, BingoCard). Extending a program across several files is something I have never ...
5
votes
2answers
270 views

Refactoring farm code

I have a code which was not refactored at all. I refactored it to some extent, but stuck at a point where I cannot think of anything further. Tractor.java: ...
5
votes
3answers
172 views

Creating date strings and setting dates

I've created a Java class, Date, in which I basically create date strings and set dates. Is there anything I can do besides adding comments to improve/shorten my ...
5
votes
2answers
2k views

“Deal Or No Deal”-style game in Java

This game is explained here. Could this code be more efficient? The Game Class ...
5
votes
1answer
127 views

Batch process as an OO design solution

I was given the task of batch process a single-level control break program to produce a lecturer information report by lecturer from a university course file. I have attempted to create a solution ...
5
votes
2answers
111 views

A simple web-app code - user registration. Is the layering ok?

So knowing the little pieces is something different and putting them together is something different. Here is the code where I try to follow good oop practices and 3 - layered structure. Any ...
5
votes
1answer
101 views

Writing an effective method that reflects good OO design and fixes this broke method

I'm working on my personal project and have recently had a bit of trouble with a method I wrote during the week. This method compares user input from the same ...
4
votes
2answers
248 views

Managing employee information

I have created a program that allows the user to view/add/delete employees and also view employee payslip, either weekly employee or monthly employee, which is all done in the console. My programme ...
4
votes
3answers
317 views

Simple spin game

I see many many programs that are written out of the main method. But most of my programs are written in main() and access some ...
4
votes
2answers
6k views

Blackjack code review

I am very new to Java and programming theory and am desperately trying to improve my knowledge. This is the first program I've made without help and really would appreciate some feedback. I know there ...
4
votes
2answers
264 views

Improving my Java object-oriented? Review!

Did I improve since then? I have been writing this program today, and tried my best to improve my object-oriented understanding. Mains.java: ...
4
votes
2answers
374 views

My first OOP piece… how have I done?

This is my first OOP coding project and I would appreciate any constructive criticism as to how I could have used the benefits of Java and OOP to better effect. How would you have implemented this ...
4
votes
2answers
3k views

Random password generator

I just wrote my first Java class, and I wanted to share it with you and maybe get some quick check from more experiences coders than I am. I want to learn OOP, and Java is just the tool I thought was ...
4
votes
1answer
113 views

Avoid flickering on game screen

This is the smallest SSCCE of my project. I get flickering on the screen with this code. Main class (on which I start the application) ...
4
votes
3answers
154 views

Is there a better, more object oriented way to write this Finder method?

I have several lists of objects which are stored in different locations, based on what they are and who needs them - the system, or the user, for example. There are times where I am only given an ID ...
4
votes
1answer
121 views

Simple class to represent progress

Progress class was written using TDD. Interface of this class (pseudo-code): ...
4
votes
2answers
80 views

Review of java interface for constructing brain model

I have built a partial human brain model and the following is an example of how I use all the classes. I was wondering if anyone could critique my implementation strategies because I feel like the ...
4
votes
1answer
801 views

Object Orientation and Style - Document Clustering / NLP in Java

This is a solution from the CodeSprint 2012 coding competition. Any suggestions on ways to improve the object orientation or general style would be much appreciated. The code takes several text ...
3
votes
1answer
94 views

Throw an exception to control the flow of code execution

There is a recommendation not to use an Exception to control the flow of execution. This gives me a reason for doubt when I do something like this: ...
3
votes
3answers
259 views

Beginner to OOP: Do these classes properly represent the objects in Java?

These classes are part of a program I am working on to convert Arabic numerals to Roman numerals and also the reverse. Do these classes look correct for representing objects in Java? ...
3
votes
2answers
89 views

Help me improve my Hangman app

I just created a Hangman app (same game mechanics mostly) using Java. I did this mainly to test my knowledge in OOP design/coding. I'd like to know your thoughts on my code The whole project is on ...
3
votes
2answers
144 views

Subclassing or not?

I have a class called Foo ...
3
votes
2answers
124 views

Constructing a binary tree in java

I am constructing a binary tree. Let me know if this is a right way to do it. If not please tell me how to?? I could not find a proper link where constructing a general binary tree has been coded. ...
3
votes
2answers
131 views

Looking for a better solution to my OO code

I would like if this could be kept to a post providing concrete examples of how I could solve my problem better, and not about which one would be "best" as such :) I would simply love some insight to ...
2
votes
5answers
514 views

Request for Comments: Singleton pattern implemented in Java

I have several utility classes who should only ever have one instance in memory, such as LogHelper, CacheHelper, etc. One instance to rule them all. I've never implemented Singleton in Java before, ...
2
votes
3answers
334 views

Clear ArrayList

I create class level static ArrayList by the following line. static ArrayList<Student> studentList = null; Then I create and fill ArrayList with some ...
2
votes
2answers
909 views

What's wrong with static utility classes, versus beans?

My inclination is to make these methods static: ...