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 demands that someone review my code.
About the code: I have not started the graphics yet. I have jus...
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 demands that someone review my code.
About the code: I have not started the graphics yet. I have jus...
I wrote this code, based on the Newton-Raphson method, to find the square root of a number. I'm wondering how I can optimise this code, as I am out of ideas.
#include <stdio.h>
int main(void)
{
float n, x, i;
printf("Enter the number you wish to find the square root of.\n");
pri...
I want to use the output of the terminal command ldd:
root@kali-vm:~/Desktop# ldd simple
linux-gate.so.1 => (0xb7722000)
libcurl-gnutls.so.4 => /usr/lib/i386-linux-gnu/libcurl-gnutls.so.4 (0xb769c000)
libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xb7539000)
libidn.so.11 => /usr/lib/i38...
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
Why does my code return 1?
steps taken
each number can be a prime, set range 1 to number
find out which numbers in range are number.prime?
print t...
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
Why does my code return 1?
steps taken
each number can be a prime, set range 1 to number
find out which numbers in range are number.prime?
print t...
@nhgrif it's non-working code, but it's also very unclear - I voted to close as unclear and then noticed Why does my code return 1?..... bah, off-topic anyway.
the blockquotes are unintentional: >> The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? >>>Why does my code return 1?
This is the outline for code for a Pacman game. Please give me any suggestions you have on what my next steps should be and how I should clean up the code. The more specific, the better. But basically, anything you say will be fine. Please write the suggestions as answers or in the comment sectio...
I found a problem here. I am sharing the problem and my attempt at solution. I would like to find out if this is the best approach possible.
One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and play...
I have a jquery function which adds tag to first row of table. I tried using append, however its not working, so i got a solution which is very slow and it somehow gives error "Script on this page is causing internet explorer run slow..."
Function is as
jQuery.fn.fixGridView = function () {
...
Time: 1 hour
Design a data structure to store an organisation hierarchy. Create a Employee Database for an organization. Each employee may or may not have a manager. One employee may have many subordinates. This can grow upto any level.
Find direct and indirect subordinates for a given employ...
I've built a base class that I use a lot in my iOS app t make calls to web services. I built the base class to make the actual call and this base class is only ever used by another class.
The idea was that should I decided to change from AFNetworking to something else, I would not need to rewri...
May there be any performence and/or code standard improvements on the following LineOfSight code?
static List<Coordinate> getIntersects(Coordinate c1, Coordinate c2) {
// Bresenham's line algorithm from http://rosettacode.org/wiki/Bitmap/Bresenham's_line_algorithm#C.2B.2B
List
Below code is showing error for correct_script_video.avi.But it is working fine for other videos.This video is present in current path but still its showing error.What is the reason?
Error is:
Error in VideoReader (line 132)
obj.init(fileName);
Error in framescheck (line 1)
obj = V...
Continuation of this question: Unit of Work with Generic Repository Pattern MVVM, vol. 3
I have made some changes.
The methods GetFeedBySomething() have been replaced by Find()
GetRepository() has been added to UoW
I separated DAL from Model
Model inherits IBaseEntity from DAL (not sure is it ...
I'm really excited that I got my code done without the help of the web :)
however, I always come here to give and take. I learn here a lot and I appreciate the help of you. also there might be someone out there who might use some help from the stuff I post, even though it's basic :/
so anyways, ...
I've been trying to figure out a clean way of managing mappings between two objects. In the case of this example, it's two hashes. This spec should illustrate the problem at hand:
describe 'key mapping' do
let(:have) { { data1: 'foo', data2: 'bar', data3: 'baz' } }
let(:want) { { LINE1: 'foo...
Recently I've attended an interview, where I faced the below question:
Question: "There is an sorted array. You need to find all the missing numbers. Write the complete code, without using any generics or inbuilt function or binary operators. First and last terms will be given. Array will be sor...
So someone is hiring someone for Java, and asks to write code that doesn't make use of all possible Java features, is that not counter productive? Would I even want to work for a company with such an interview process?
Recently I've attended an interview, where I faced the below question:
Question: "There is an sorted array. You need to find all the missing numbers. Write the complete code, without using any generics or inbuilt function or binary operators. First and last terms will be given. Array will be sor...
I want to build a service pricing list for bonded zone company, it provides many services that have different methods of calculation, and each type has many prices according to customer groups. This is the model:
public abstract class Service
{
public virtual int Id { get; set; }
...
I have made a program in C++ simulating a dictionary with very basic functionality .
I do not have much experience in File Handling with C++ .
Also, I want it to run on Linux and Windows.
It would be great if you could review/improve it on these things -:
The File Handling part of the code. ...
I can understand if there's some requirement like O(n) or O(n^2) and you are asked to give an implementation that doesn't invalidate that... but plain outright banning libraries?
I'm more inclined to think that a regular programmer should know how to use libraries, and than when you are intending to hire a programmer for implementing algorithms, that you would give some harder example
I haven't ever been to an interview myself though I must say, still at university
Maybe I'll be crazy enough one day to just do such a thing for fun
Unrelated to this convo, since earlier this morning I am considering some functionality which would be placed between java source and the javac to compiled bytecode, with integrated IDE support
But still need to experiment a lot to see if it's even feasible
Later today I can explain a project coordinator of mine how the github issue tracker works... I'm a bit tired over getting emails etc. about bugs, features
and the worst part is: this is going to be implemented by students so they must understand it
the problem with the visitor is: I loose the clean function interface as I cannot simply return the resulting representation (that would forbid using one base class for all visitor implementations as the return type changes)
and another problem is, that the previous design allowed for easy caching of values at the nodes which would be prevented in the visitor implementation but is necessary for efficiency
@Nobody It's too complicated for me to just understand I'm afraid I can't be of much help
This is going to break some minds for people reading this: It is of the signature Card -> void, hence an implementation for this functional interface is a lambda that is an implementation of the Consumer<Card> functional interface.
in this semester I will be around during the exercises to catch up some flaws of the code and improve it but in the further semesters they will be on their own with the other one (who might himself have problems understanding the code)
@nhgrif Naming the prime factors for another number was probably intended to be an example of what prime factors are - for those few around here who doesn't know what it is. And perhaps it was also an example for "The code produces the correct results for this number"
@Jamal I actually think that comment by n.m. was very helpful. He was right that the question belongs on CR. The fact that the question did not contain the code within the question is a minor detail IMO - We can't expect users on other SE sites to know about that rule.
@SimonAndréForsberg sorry, but I have to disagree there..
we can expect users on other se sites have enough brains to deduce, that a codereview needs some code to be reviewed...
and if they can't be bothered to think about it, before recommending a site to repost a question, or adequately express concerns on that, we should be free to remind them, that their head is not for wearing hats only..
(and I really, really like the fire-pic, but the sky pic was a bit to 'empty' .... I could not find anything to focus on (which is probably the point).
I love this debate with Netbeans... Claims code doesn't compile, I add an extra cast, it compiles, claims the cast is redundant, I remove it, code doesn't compile, repeat
@Vogel612 I understand your thought, I think n.m. did more good than harm in this case though. Sure, it would be even more helpful if it was written "If you post your code within the question itself then go to Code Review", but I'm somewhat realistic. We struggle so much getting people to understand that CR is not for broken code, if they aren't completely aware about all of CR's rules, I think that's OK.
A couple of comments first
It would be better to let your divide method should return an int, not do the output to System.out itself. Do the output in main like this:
public static void main(String[] args) {
System.out.println(divide(-4,-10));
}
The variables N and D are short and don't f...
I use the rails_best_practises gem and it came back to me with this alert:
/../db/schema.rb:65 - always add db index (comments => [user_id])
So in db/schema.rb, the line 65 shows the schema of the comments table.
create_table "comments", force: true do |t|
t.string "commenter"
t.te...
Regarding your current code:
Public or private
You have three public static variables, but your findMissingNumbers method is private. It would be better having it the other way around. You wouldn't want outside code to modify your static variables, those are meant to be used only by your findMi...
@Vogel612 I am a bit sad that none of the other posts pointed out the flaws in the original code. Many of those other posts really deserves some comments...
I guess @Singleton only Instantiates a single instance in any case and @Stateless has a few in a pool, but if there's no need, It would also just instantiate 1..
However, @Singleton should probably be used for... well, singletons with state.
Exactly, one could. If you wanted to. For whatever reason. Probably when you don't have an object nearby that is ready to use, you just create a new one.
Because there is no state, the application server is not required to ensure that each method call is performed on the same instance. This makes stateless session beans very efficient and scalable.
Conventions:
That is in my eyes the definitely biggest problem in your current code. Naming conventions. All programmers agree, that naming is one of the most difficult things to do. Therefore it is useful to define conventions to abide when naming. The C# convention for naming methods is not ca...
I remember that I have seen some good comments on answers that just provides a core-dump as an alternative way of doing something, anyone has such a comment nearby?
This is a great code review opportunity because your program 1) works, and 2) has tons of room for improvement. Almost every line of your code could be refactored, but don't take that negatively. Every day I come out of code reviews with changes suggested to my awesome code. It's just how the bus...
Awesome review by quite new user with only 168 rep.
The code below is part of one of my projects called largetext, which actually stemmed from a question on StackOverflow.
The goal is to provide access to a very large text file as a CharSequence so that it be usable with not only java.util.regex but also grappa.
In the next version, I want to pr...
Basically I want some help in reducing the bloat of this code. I am new to javascript so this represents an attempt at learning jQuery by doing. All of this code works as I want it to, but it is not efficient or maintainable long term.
I realize there is no context for what is going on, but I fi...
I'd like to address my take on the thorough answer that ryan posted.
While I agree that the two statements can be determined to make an analogy (and I agree with ryan's answer on the majority of points that he made, I personally don't believe it is a very effective one.
I'd like to emphasize th...
Speaking of which, I have to say that from a European point of view, the idea of specific gun shops, as exists in the U.S., is just... completely crazy to me.
Version 1
public class User {
public String firstName;
public String lastName;
public User(Context context){
SharedPreferences pref = context.getSharedPreferences("Session", context.MODE_PRIVATE);
this.firstName = pref.getString("fname", "");
this.lastName =...
Okay, so I'm a self-taught programmer and have been brushing up on all the 'boring' bits that CS students do that most of us self-taught ignore. Things like Algorithms and Data Structures (particularly). So I found a nice exercise book that explains how algorithms work, but then leaves the implem...
I am having an issue with my Lambda expression in Netbeans 8.0 and am wondering if I did something wrong, or Netbeans or the javac compiler does it wrong.
I have the following code:
public interface HandView extends View<Hand> {
void onCardAdded(final Card card);
void onCardPlayed(fina...