> If your overridden Equals method returns true when two objects are tested for equality, your overridden GetHashCode method must return the same value for the two objects.
I've upvoted this answer because it makes a very good reference for implementing Equals and GetHashCode. However if pin.Equals(other) == true, then pin.Id == other.Id, so pin.GetHashCode() == pin.Id.GetHashCode() == other.Id.GetHashCode() == other.GetHashCode() (thanks @mjolka) — Mat's Mug ♦57 secs ago
@Mat'sMug huh? You lost me. Might have made more sense if the code could have been properly formatted. — RubberDuck18 secs ago
I sense a duck coming
If Equals was based on Id and GetHashCode on the 4 fields involved here, then yeah OP's implementation wouldn't have been compliant. But it is ;-) — Mat's Mug ♦41 secs ago
I've got this DB table, called dbo.Settings. Right now I have five columns in it. Name (nvarchar(64)), Value (nvarchar(128)), GroupId (int), ValidValuesMessage (nvarchar(MAX)), and DisplayName (nvarchar(MAX)).
The problem, is that Name is the PK.
And I use Name in the programme to get the setting values.
This question would be more appropriate for the Code Review stack exchange site, however be sure to read their how to ask guidelines to make sure your question is in a format that is on topic for that site. — Scott Chamberlain40 secs ago
I relatively new to programming so forgive me for my code. The goal is to create a simple dice game in which there are two players in Javascript. Each time the "roll the dice" button is clicked, it triggers the roll dice function. the roll dice functions rolls two dice using the random function, ...
Then you need to narrow down on the issue and ask a more specific question; as it stands this question is too broad to be on-topic. Also, make sure you take a look at the tag wiki for the code-review tag ;-) — Mat's Mug25 secs ago
COBOL
Sure! "Even a monkey can do this!"
Here is a simple COBOL program that will sort the input for you. Read the comments to see exactly how trivial and extensible it is. The real benefits of this are that it is tried and true mechanism, it does not rely on new and relatively untested langu...
Well, I got a surprise in my notification inbox just now.... apparently I was just awarded a mortarboard on PCG (Code Golf).... except, I have had no reputation on that site for a while, and I was awarded that badge a couple of years ago...
This is what my notifications currently look like:
T...
I made a agario single player version(soon to become a multi player one using socket). What can be some improvements?
Controller:
package agario;
import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt...
I am new to Python and beautiful Soup. Here's my HTML
I would like to replace the 'src' of this image (there is only one occurrence of the image so no need of a loop). The new src which is a hyperlink is coming from an excel file which is read into my python file as a variable. Can this be done...
I have a very simple Node application that routes requests to /users to the following file:
users.js
var express = require('express');
var router = express.Router();
var User = require('models/user');
var sequelizeSuccessHandler = require('lib/sequelizeSuccessHandler');
var sequelizeErrorHandle...
I'm starting to learn about data structures. I'm also learning to code in c. The stack is the simplest of all data structures so I'm trying to implement an ADT stack with dynamically allocated array in c. This implementation does have one obvious problem i.e. it hoards memory even after popping t...
Looking for a better way to manage employee photos for employee records in our database, and a way to query for the employee photos while having them on disk I have used a FileTable to store all the EmployeePhotos.
Then in my Employee View I created a join using substring's... Which I am concer...
Following is a problem from CodeChef:
Transform the Equilateral triangle keeping two sides fixed and alter the third side such that it still remains a triangle, but the altered side will have its length as an even integer, and the line drawn from the opposite vertex to the mid-point of the al...
I'm starting to learn about data structures. I'm also learning to code in c. The stack is the simplest of all data structures so I'm trying to implement an ADT stack with dynamically allocated array in c. This implementation does have one obvious problem i.e. it hoards memory even after popping t...
Could you help me further improve this code, which includes some feedback from this site already (Find common "characters" in 2 given strings)?
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.C...
Could you help me further improve this code, which includes some feedback from this site already (Find common "characters" in 2 given strings (rev2))?
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.s...
I am writing an encryption class using Crypto++.
The idea is the client connects using RSA(Encrypt,Decrypt) with username, password, 32 byte key.
The server will then return using the stream cipher(simEncrypt,simDecrypt) a session id.
Then any communication between the systems use the stream...
Could you help me further improve this code, which includes some feedback from this site already Find common “characters” in 2 given strings (rev3)?
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.uti...
Hi again, *Monking!*I am thinking of making a convenient, arbitrary precision java library that provides functionalities for encapsulating surds, complex numbers, constants like pi, e, etc.
I wnt teh opinionz...
(Is there something wrong with the MD renderer? I'm sure I posted valid MD)
Hmm... Since the room is empty now, I'd better post my requests. They are:
My suggestion: Don't reinvent that wheel. That's a big wheel to reinvent. If you want to reinvent a wheel, there are many other wheels you can reinvent instead.
Wikipedia says one only need pi upto the 39th digit after the decimal to calculate the volume of the universe accurate to the nearest length-of-a-Hydrogen-atom.
The table below is a brief chronology of computed numerical values of, or bounds on, the mathematical constant pi (π). For more detailed explanations for some of these calculations, see Approximations of π.
== See also ==
History of pi
== References ==
== External links ==
Borwein, Jonathan, "The Life of Pi"
Kanada Laboratory home page
Stu's Pi page
Takahashi's page...
I doubt your users would even be interested in pi upto the 39th digit. And if they do care about that, they will probably go with another, more well-known, library instead of yours...
I don't want to discourage you from making anything, but I'd like you to reflect on why you are really making it. And consider what things your target audience care about, and why, and all the implications...
Functional programming might be a motive. Also, convenience.
And clarity.
@SimonForsberg BTW: (Another topic). If I write some code and add a (c) ambigram_maker 2015, does it become a copyright? Is something else required to copyright my code?
Also, is YAML used these days? The project seems to be stuck in 2009.
If a repository has no license, then all rights are reserved and it is not Open Source or Free. You cannot modify or redistribute this code without explicit permission from the copyright holder.
I'm unsure of the legal implications of actually pulling the source local and building/using the so...
But if you want to make a library, then what license do you really want to apply to it? Read through a couple of licenses and think: Do I want other people to be able to use my code? Do I want others to modify my code? etc...
but it's all up to you, depending on what rights you want to give people to your code.
I used to be extremely restrictive with my code, especially my Minesweeper Analyze code, because I strongly believed that a company would take my code and use it and make money from it.
Now, I've had that code open source for quite a while and to my knowledge, no one has made money from it yet.
The best way to make money of your own code is to make it open source, so that other people can look at it and realize how awesome you are and give you a job.
Exactly. I believe in what the original hackers intended. But sadly, many don't want people to know how they solved a problem that (they think) is challenging.
@SimonForsberg I used to believe that its mandatory to add javadoc to your code before publishing it. You proved me wrong. ;-)
I was reading an article on Wikipedia about memoization, so I wanted to try and apply it. I am fairly new to this subject, so I thought I'd start small. Does the program use memoization correctly? Is there anything that I can improve?
#include <iostream>
int fibonacci(int num, int* memoize);
i...
Could someone please review my code and let me know if there is any scope for optimization for better performance.
package com.gmail.practice;
import java.util.Arrays;
public class Stacks {
private int top;
int size;
int[] stack;
public Stacks(int arraysize)
{
size = arraysize;
stack...
Original Post
This ain't something not working but just I'm confusing about how to do it, I want to fetch the values from my DB based on users' preferences that been chosen earlier.
These are the steps will be taken for my process:
User will select from images (will add HTML images then will w...
I wrote this simple class for calculating the nth prime:
public BigInteger calculateNthPrimeNumber(BigInteger n) {
if (n.compareTo(BigInteger.ZERO) <= 0) {
throw new NumberFormatException(
"Can not calculate nth prime number for n=" + n);
}
BigInteger candidat...