I have written this code for a two input calculator. Is there anything I can do to make this code more efficient?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class CalcGui extends JFrame {
private JButton buttonZero;
private JButton buttonOne;
private ...
See the previous and initial iteration.
Now I have rather more cohesive code:
BottomUpMergesort.java:
package net.coderodde.util.sorting;
import java.util.Arrays;
import java.util.Comparator;
/**
* This class provides static methods for sorting object arrays using
* bottom-up (non-recursi...
A Java project I have to maintain contains code that looks like:
InputStream is = getClass().getClassLoader().getResourceAsStream("project.properties");
Properties props = new Properties()
props.load(is);
// Proceed to load configuration from the properties resource
I can't wrap my head around...
@kervin "But I cannot get the output what I am expecting" indicates that the code does not accomplish what it's meant for. Accordingly it's not "working as intended" and off-topic for codereview. For more information, see meta.stackoverflow.com/questions/253975/… — Vogel61244 secs ago
Listen to what I'm saying. Listen to the downvotes. This is not an answer. If you don't remove it, a moderator will. Do not misuse answer to contemplate the nature of the universe, ask new questions, expand on your original question, etc. — matt2 hours ago
(Game: locker puzzle) A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, and closes every other locker. Stud...
I have recently started researching some computer vision, and in the process of discovering some interesting things I have been compiling some functions that allow me to manipulate images at a low level. I am not interested in replacing any of these functions with already existing, build-in funct...
This question could be suitable for Code Review, as long as (a) your code works as intended, (b) your code is real code, rather than example code, and (c) your code is included in the body of the question. If you wish for a peer review to improve all aspects of your code, please post it on Code Review. — Phrancis28 secs ago
Take the following relatively simple function:
function add_to_set(array &$array, $element)
{
switch (gettype($element)) {
case 'object': $hash = sha1('o' . spl_object_hash($element)); break;
case 'integer': $hash = sha1('i' . $element); break;
case 'double': $hash ...
La-comadreja @ StackOverflow invited me over here to post my code for review. Please any help is very much appreciated!
1) How can I limit the user to spend a "Tag" on a different "Skill" on each inputFirstTag, inputSecondTag, inputThirdTag
Everything works fine until Round 2 rears its ugly head...
The problem is that you haven't defined what you mean by better. Have you identified a specific problem in your code? Is something not working correctly? Those are the types of questions we can answer. More general questions like "how can I improve this" are harder to answer, and is what CodeReview was designed for. — Kevin Workman52 secs ago
var checkbox = document.getElementById('checkbox');
var checkbox1 = document.getElementById('checkbox1');
var delivery_div = document.getElementById('delivery');
var delivery_div1 = document.getElementById('delivery1');
checkbox.onclick = function() {
console.log(this);
if (this.checked) ...
We have some code to populate a CMFCPropertyGridCtrl grid with controls that is based on copied samples. We are currently using Visual Studio 2012 but intend to upgrade to VS2015 soon. A typical excerpt is:
void CPropGridProps::AddPropertiesJoint(const bool bIsDataEditable, const CJointDefault& ...
(Game: locker puzzle) A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, and closes every other locker. Stud...
(Game: locker puzzle) A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, and closes every other locker. Stud...
I would appreciate some help with camera movement and zoom.
Is there any easier way with more clean code or simply how can I improve it?
Window size: 800x600
Image size: 1200x900
This is my code so far (you can move with the camera only around the image and use zoom):
package game.engine.gui;
...
This question could be suitable for Code Review, as long as (a) your code works as intended, (b) your code is real code, rather than example code, and (c) your code is included in the body of the question. If you wish for a peer review to improve all aspects of your code, please post it on Code Review. — Phrancis38 secs ago
The author of my book does not release odd-numbered solutions to students, so I can't check my solutions. I was wondering if there was a better way to solve this problem without simply printing out the square roots.
Here is the question:
(Game: locker puzzle) A school has 100 lockers and 100...
Write a program to enter the string as input and replace if space is there in the character by consequent character.
For example, input string
I love java
Output string
Illovejjava
@Jamal Actually, a lot of PPCG questions are gimmetehcodez type. Or course, it will probably be turned into a code golf question, and she'll only get unreadable answers...
you know, looking at this code the code looks like it works in both instances, I am not sure why they are saying they don't understand the second part, it's all there.
Recently, I implemented an RenderBatch class, which purpose was to render any objects, using a specific shader (with its configuration). I would like to ask you, if I could improve on the way my render process works; any suggestions, or ideas are welcome ! Here is my code :
RenderBatch.h :
#p...
I want to write a program in java to remove the user input word from a string and the remove the repeated characters from the string.
I have written the code given below:
import java.util.*;
public class wordcut {
public static void main(String[] args)
{
String line, word;
...
i am trying to implement a "find nearest location" from a given latitude and longitude using mysql. i have 8000 locations stored in my wordpress website.
i managed to write this:
SELECT
b.ID,
SQRT( POW(69.1 * (b.latitude - 51.5073509), 2) + POW(69.1 * (-0.1277583 - b.longitude) * COS(b....
A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted S1, opens every locker. Then the second student, S2, begins with the second locker, denoted L2, and closes every other locker. Student S3 begins with ...
This question is not ready to be reopened, and if it is reopened, I will be voting to close it as too broad. This isn't a comparative review. It is two questions posted as a single question. I understand we allow comparative review questions (even that his debated here), but that's not what this is. There is no description about the differences, there's no logic given for why we should make the effort to review two separate implementations here. This needs to be two separate questions. — nhgrif48 secs ago
We have a couple of checks in current project like this:
if(json.something.blabla == "True")
It's extremely bad. I came up to conclusion writing something like this:
;(function(){
var methods = {
isTrue: function() {
/**
* Takes a single argument and returns
* tru...
I cast a single upvote on March of last year, but I didn't even post a question until February this year, and I just answered my first question today. That said, that single upvote got me the yearling badge
@Malachi - You could also use DataContractJsonSerializer in System.Runtime.Serialization.Json.dll, which is part of the .NET framework, so long as you decorate your objects with DataContract attributes.
It's a little slower than the Json.Net equivalent, and it's literally only going to get you serialization/deserialization, but it sounded like that's all you need
@SirPython This is why I love the codeless query. However, it may still not list questions with backticks, so I suppose there may be other redacted questions out there.
I find it awesome that we were able to keep two great moderators AND add two of our most dynamic users to the team.
Simon and Mat's Mug, you guys will certainly get the best mentoring possible from the old timers and together I'm sure you'll raise the bar even further for this site!
Congratul...
^^ @Mat'sMug I didn't know you were into dynamic languages
@Mast I knew that 200 and Jamal wouldn't have any trouble getting elected, so I voted for some of the lesser candidates. I'm positive that my vote was not exhausted.
http://www.commitstrip.com/en/2015/07/15/a-brief-history-of-flash/ CommitStrip - Blog relating the daily life of web agencies developers A Brief History of Flash CommitStrip 1436981064
what is the best way to organize my source code
Organize packages by category
com.example.myapp.activities - Contains all activities
com.example.myapp.adapters - Contains all custom adapters
com.example.myapp.models - Contains all our data models
com.example.myapp.fragments - Contains all frag...
Hy Guys. I was asked to create a function that return first UNIQUE integer from given array of integers. In a case of success the function return the unique number in a case of failure return -1. The complexity should be O(N*log(N)) My solution is:
function solution(A) {
var returnNumber = ...
Ugh, debugging hardware visually usually isn't a problem. Unless they carry high power LEDs.
Turns out somebody switched the 1.75V LEDs with 12V LEDs. I was wondering why I had trouble decoding my screen every time I took a look at the darn piece. 24W of LEDs does that with your eyes.
Last month's announcement about our updated criteria for graduation and site closure sparked some solid examination into the intended nature of public beta and graduation.
One thing these discussions showed us is that, contrary to what the Community Team had long believed, getting a custom desig...
We're lucky that we had an election at all. It was largely because rolfl resigned and we pushed hard to have an election instead of another appointment.
I think the concept is great, but the motivation for the privilege levels is somewhat flawed.
It should perhaps be considered on a case-by-case basis, but the privilege threshold is one of the key reasons why, for example, I wanted Code Review to graduate.
Escalated privilege thresholds is a go...
The recent elections on Blender, Network Engineering, Cryptography and Code Review (all betas) went reasonably well. On some of these the number of candidates was barely enough to hold an election, but that might be attributable to a glitch with election notifications, which was since fixed.
S...
i wrote some code to transalte numbers ( for now just positive, up to the 32bit limit ) into english words.
Everything works and i'm happy. I searched through the site looking for a comparison code but i couldn't find a C++ version that goes above 999 to use as example
I had a few assumptions:
...
I have to modify an existing VBS script that downloads a PDF from a remote location and renaming, then moving to a source directory on another server.
Now, we are introducing a new PDF file from the remote location and it has to be renamed and moved to another source directory on another server....
I could replace it by the real code, but it's only one line, guys. It doesn't really matter in this case, because question is not about this particular line
@RomanPushkin - consider editing your post to make the "example" usage clearly just a use-case (probably by block-quoting it), and making it clear that the prototype methods are what you actually want reviewed.