instruction stringlengths 71 39k |
|---|
Previous review of this project:
Card Deck class for a Poker game - version 2
This time, I considered combining both classes into one header file so that I can reduce my use of #include and to keep them together. I also did this so that I can define my const std::string variables only once for both classes. However, ... |
I have these two functions and I was just wondering if there is any way to shorten the line of code with the many && statements. Shortening of the rest of the code would be cool too, but it's not necessary. I'm trying to learn if there is a better way to accomplish this though.
# Accepts two stroks and determines if t... |
I wrote a function to find a specific fibonacci number, which runs in O(lg n). Then I modified it with a template. Though it works, I'm new to template and want to know if I used template correctly. Moreover, I wonder whether someone who has a BigNumber class
can use my function without modify my source code.
#include ... |
Normally I do this:
if (Animal is Dog)
{
Doc d = (Dog)Animal;
// d. etc..
}
else if (Animal is Cat)
{
Cat c = (Cat)Animal;
// c. ....
}
Is this a good way or are there better ways to implement this code above (performance, ...) ?
Should it be like this?:
Dog d = Animal as Dog;
if (d != null;)
{
... |
Lets say I build functions.php and I have 3 functions inside of it that I use. Lets say that I build a 4th function, but what I really want to do is simply put the instructions of function 4 into function 1 for example. Is there anything wrong with this?
Consider my example here, where I have included a function inside... |
I had already posted a question about the one I am asking right now.
To quickly revisit the scenarios:
I am trying to generate reports which involve fetching data from a DB, writing data to a CSV file, and sending email. I am pulling data for all the reports in the same format since I wanted to keep the DAO layer and C... |
I have an email contact form that is PHP and very basic. I am concerned, however, that injections might be possible through it. So I was wondering if anyone with far superior PHP skills than myself would be willing to take a look and see if I have any gaps or vulnerabilities in my code that could be exploited. I very m... |
I'm looking at a class diagram and it shows a method like this:
SavePrintOptions(bool,bool,bool,bool,bool,bool,bool,bool,bool);
where each of the parameters match up with save options (checkboxes) in the UI. How could I refactor this signature to reduce the number of parameters?
|
I have a string of four bits which represent true/false values. There are only seven valid options:
1010
1110
0000
1101
1001
1000
0101
There are three options which could potentially be selected which are not valid and that I want to check for before I proceed with some other code. These are:
0110
0100
0010
I want t... |
I've been programming for about 5 years now, mostly in C++ and Java, while continuing my college education in Computer Science. As an adult student, I'm always looking for opinions and ways to improve from professionals in the field. Aside from reading from numerous text books, I've read these forums for tips and good ... |
I have a need to express something like this:
while(bytesToWrite > 0)
{
// get the NEXT location to write from a Key/Value collection of locations
// read a packet from a file at the specified location
// write some bytes to the packet
bytesToWrite -= bytesWritten
}
This was my first attempt:
var di... |
So I'm using the acts_as_taggable_on gem to tag 3 different models: Question, Blog, and Video
Each one has a site_id to distinguish which site they show up on (SaaS-ish).
I wanted to get all tags for a specific site without saving site_id right on a Tag or Tagging.
I came up with the following, but I feel like there mi... |
I just wrote this, and cleaned it up as much as I could. A couple things worry me:
I change the scope of $(this) twice (and apparently don't know how to use =>)
The big if if/else statement. Is there a better way to write that?
Also, it's an IIFE, and the big identing makes the )() at the end look out of place.
emp... |
This is just a simple script for testing sprite sheet animations. I'm trying to improve my code style, so I'm curious about suggestions anyone might have about best practices or readability.
<html>
<head>
<script>
//just a shim to provide requestAnimationFrame support in different browsers
... |
Is this a good implementation for Equals and GetHashCode for a base class in C#? If it's not good enough, can you suggest improvements for it, please?
public abstract class Entity<TKey> //TKey = Type of the Key
{
private string FullClassName;
private bool KeyIsNullable;
private Type BaseClassType;
pr... |
I have that $db, that I will use again and again to connect to the database. How do I put this in a central location so if I change my db I will not have to rewrite a bunch of lines of code? Everything I've tried so far just gives me an error concerning variable scope, the variable is not declared in my functions, so I... |
I have inherited an application that has code to save and populate values in an ASP.NET checkboxlist control. The existing code is very lengthy and does not appear to be efficient to me. I plan on rewriting this application and have complete control over the database design.
All of the checkboxlist items are stored in ... |
I have a method that takes a generator, converts it into a tuple to sort it, then into a list. It works perfectly, but being as I am fairly new to the Python world, I keep asking myself if it is worth doing or not...
@property
def tracks(self):
if 'tracks' not in self.cache:
s = Search(Track)
q = {... |
Sometime ago I saw a code which packed key,value pairs into several GET messages. That code had a bug (that is why it was shown to me: as the example of beautiful code which doesn't do what it should).
Today I decided to write this code out of curiosity and for training.
This is what I have written:
def group(url,D,lim... |
Trying to implement this API in a way that works pre and post jQuery UI 1.9:
I have a subtle feeling that there should be a more elegant way.
/** Prefix number with '+'/'-' or return empty string for 0. */
function offsetString(n){
return n === 0 ? "" :(( n > 0 ) ? ("+" + n) : ("" + n));
}
var posOpts = {
at:... |
I wrote this a couple months ago and just wanted to get some feedback on it. In the printBoard() function, you see I commented out the system function. I've read this is considered bad practice. Does anyone know of any alternative to clearing the terminal window? I thought it'd be a nice touch to clear the window ins... |
Here is the link of the problem for which I need your help.
I came up with solution and it is working fine for all cases, but it takes more time. I need your help in reducing the runtime of code. I unable to optimised it more.
#include <iostream>
#include <string>
using namespace std;
long nChoosek( unsigned n, unsig... |
I wrote a small particle engine in Java for my Pong clone.
I read that changing a texture is very expensive in OpenGL, so I tried to change the texture as few times as possible. Therefore I change the texture in the render method of the emitter and not in the render method of every particle. Although my framerate dro... |
The following is a code from one of my projects which implements a loading cache with timeout and expiry. The associated tests are here (mixed with a good number of argument sanity checks tests). I seek comments on the thread safety aspects in particular. I think it is, but I may miss something.
Also, do you see ways i... |
I read this question and answers, about if Display Annotations on model properties violates the separation of concerns between view and model. And my interpretation of their answer was "No, not if you're using a ViewModel for Display Annotations". But additional separation of concerns questions arose as I began imple... |
I'm new to hand coding a PHP form/email submission. Are the security checks I've included here good enough? Or is this super vulnerable to attacks?
My main concern is protecting the email login credentials below. Any feedback much appreciated.
Thank you!
// IF WE'VE SUBMITTED A FORM
if(
!empty(... |
When I wrote this it just felt messy due to the null checks. Any good ideas on how to clean it up would be most appreciated.
def getItemsInStock(self):
itemsInStock = []
items = self.soup.find_all("ul", {'class':re.compile('results.*')})
getItems = [x for x in items if x.find("div", class_="qu... |
Previous review of this project:
Deck and Card classes and member-accessing with one header
I'm nearly finished with my deck of cards project, and this time I made changes to hide the Card class by nesting it in the Deck class. I'm still getting correct results when displaying the deck. However, I do now realize that... |
I want to know if what I have coded is good enough or if there is any simpler/faster/better/less size taking substitute.
I am trying to take input from push buttons and I also want to remove repeated input so I coded like it and saved in a variable key. I used internal pullup to eradicated random input from digital pin... |
Update: Now that https://github.com/bionicspirit/scala-atomic is available, I have less of a need for this.
Am I doing anything bad? I wrote this class to allow modifying an atomic reference with the assurance that two threads modifying it will not step on each other's toes. To illustrate:
val x = new AtomicRef(List.em... |
As a bit of a learning project, I decided to take the concept of proxying objects a bit further and extend it to creating proxy classes which create proxy'd objects. I originally found the idea of proxying objects in python on Activestate. I'm currently using a very odd pattern (creating a class with just staticmetho... |
Some time ago I had to make a memory game as a college project. I spent around 6hrs coding this since I was also busy juggling exams. I'm not experienced in C# so there are probably a lot of things I could've done better, and I am also bad at conjuring algorithms. So please let me know on what I did right and what I di... |
This is probably a really simple question.
An embedded device I'm working with will store the device information in an xml file.
In my code, I want to read this xml file and freely reference to it wherever I need to, so I made a simple helper class:
public class DeviceInformation {
public static final String XML_DI... |
I have just finished my first iteration of conway's game of life as a codeing excercise. I have little experience with coding, so I think my code could use some refactoring. What i am curios about is the drivers for having a more efficient code. My code is based on a cell object:
//Defining the cells -----------------... |
I'm building an alarm set to reoccur every 30 days. I was wondering if I could get a few extra sets of eyes to look things over and see if you can notice anything I may have done wrong. Any/all input is greatly appreciated!
SOURCE:
public class WifiMonitor extends Activity {
Button sendButton;
EditText msg... |
I'm a hobbyist Python programmer with not much experience.
I wrote some code for a solution to a Tic Tac Toe AI problem on the internet.
Then yesterday I wrote a simple console Tic Tac Toe game for human vs computer play where the computer plays randomly.
So I thought it would be nice how difficult it would be to combi... |
I'm currently working on a small chess game written in Java (on GitHub). The board is modeled as a Board object with a 2D array of Piece objects :
public class Board {
private final int ROWS = 8;
private final int COLS = 8;
private Piece[][] board;
private List<Move> moveList;
[...]
}
At first, I tried t... |
class ShareModel
constructor: ->
questionaireView = new QuestionnaireView
@previewImages =
shareCurrent: -> ShareModel::getSingle(ModelView::getCurrentImage(),'current',questionaireView.weight(),questionaireView.weightUnits())
shareGoal: -> ShareModel::getSingle(ModelView::getGoalImage(),'goal',qu... |
Previous review of this project: Nested Deck class design and implementation
My program finally meets all of my expectations to the best of my ability, but I'd still like another review. Please give as many critiques as you can. I will then implement this with future games that I have in mind.
CardValuesMap.h
#ifndef... |
At the suggestion of @templatetypedef, I am posting the code for my quick sort to see if anyone can offer suggestions as to where to make comparisons. And any tips on improving the code. I am using this in conjunction with a Merge Sort and Heap sort to see how the different comparison algorithms sort an array of rando... |
I am posting the code for my merge sort to see if I can get folks offer suggestions as to where to make comparisons or if I am making the correctly already.
I will post my heap sort and quick sorts in other posts. I actually have them all in a package that runs them together but separating them out for clarity.
pack... |
Is there a smarter way to do the following without the $result variable and without the if-statements?
...
$description = BIG ARRAY
$result = array('error' => '', 'amounts' => array(5, 10, 25, 50));
if (isset($description['error'])) $result['error'] = $description['error'];
if (isset($description['a... |
I'm receiving a certain string value over the network and I need to call a function based on that value.
So this is more or less what I have at the moment:
String methodName = soapObj.getMethodName();
switch(methodName) {
case "getTemperature":
getDeviceTemp();
break;
case "getBrightness":
... |
All,
I barely have a week of angular behind me and I am still struggling with some of the concepts. Below is a piece of code I came up with. The idea is to let the user add/delete entries in a model (in practice, the model is read from a json and is more complex than what is presented). While this code seems to work, I... |
class Connection
{
private string param1;
private string param2;
private static readonly ConcurrentDictionary<Tuple<string, string>, Connection>
connections = new ConcurrentDictionary<Tuple<string, string>, Connection>();
private Connection()
{
//Prevent instantiation
}
privat... |
This is my most recent login system I have been developing. It is working with Sessions. I want to know if I am doing well, if my code contains any serious exploits, and if my logic is correct.
This is the login class, handling everything related to users:
/**
* UserHandler.class
*
* Handling login/logout and others
*
... |
I have a main form for adding and deleting records and a button that opens a child form that displays records from an access database. Child form will have buttons for moving though the rows like first, last, next, previous and search. When user selects a record the child form will close and the selected record will ... |
In my app development, I need to fetch data from backed, and it needs to implement it into an HTML page.
I've written the below code for this, but I think it's very lengthy. Can anyone give me suggestions on making this better?
Function:
var JsonHandler = function(url) {
return $.getJSON(url)
};
(function (... |
I'm trying to find an elegant and secure way to track the currently reported site. I originally just used a cookie but realized this was not very secure. I have since switched to combine the session and the cookie. It still feels a bit clumsy. Am I missing something here as far as best practices? Can this be improved o... |
This is my code which implements Nd vectors. I chose valarray as a base of the class. Is this a good idea or I simply need to make a typedef std::valarray gvector instead of writing a class?
Please review this code.
//gvector.h
#ifndef GVECTOR_H_
#define GVECTOR_H_
#include <cmath>
#include <fstream>
#include <iostrea... |
I've been getting help with this script seen below. It allows one input box to be used to put values into a text area and also display a list of the items. The items can be deleted once inserted:
http://jsfiddle.net/ZTuDJ/50/
// If JS enabled, disable main input
$("#responsibilities").prop('disabled', true);
// $("#res... |
I'm trying to develop my own math library to use on a Voxel engine, but I'm worried about Matrices multiplication. Everywhere I saw people using 4x4 Matrices on a 2D Float Array but I'm using a 1D Float Array because of performance needs.
public float[] multiplicate(float[] factor){
float[] result = new flo... |
I've never put together a plugin before but I thought this would be useful to push technology forward. It's basically a browser sniffer, but if the user has a modern browser it will reward them for keeping it up to date.
Unfortunately, the code is a little heavier than I expected (6kb minified).
I just wondered if anyo... |
Previous review of this project:
Deck of cards program using a card value map
Based on the previous feedback I've received, my program could become more flexible (it formerly created a standard 52-card deck by itself). Now, the user can add Cards to a Deck, and Card is no longer hidden. I like this approach better (a... |
I'm trying to construct something which would work a bit like Zip for two tasks, but I'm a bit worried about race conditions in this code.
public static Task<R> ContinueWhenBoth<T1, T2, R>(this TaskFactory<R> factory, Task<T1> t1,
Task<T2> t2, Func<T1, T2, R> f)
{
... |
My implementation in Progress 4GL of the Luhn Algorithm. Any suggestions on improving it?
FUNCTION fnLuhnAlgorithm RETURNS LOGICAL
(INPUT pcNumber AS CHARACTER):
/*------------------------------------------------------------------------------
Purpose: Applies Luhn Algorithm to check a Number
Notes: Returns T... |
I've been spending lot of time reading through this site and found plenty of resources that shaped up my code.
I am working on an open source project known as Quizz. It is in a primitive stage as I work only during my spare time I cannot concentrate much. For this JavaScript to work, I have a huge objects and array's o... |
I have a switch case statement containing enum values as cases. These enum values are time units. Now I want to generate a timespan by using an enum value and a long value so like this:
2 (long) Minutes (Enum value)
1 (long) Year (Enum value)
... and so on.
This is the switch-case statement:
private const double year... |
Is there any ways I can write redundant-less code without this infinite loop? I have also tried putting the conditions and the generating number, but since it has two conditions, the output number will be different.
private static final int PERCENT_97 = 3;
/**
* Returns returns a pseudo-random Gaussium number. Forumla... |
First of all, I'm trying to learn OOP PHP, so any advise will be great.
My idea is to create some kind of MVC Framework CMS kind of thing, just to learn OOP PHP and MVC well.
Let's say that I've got this code (note: I will separate the code pieces in different files, but this was just for testing):
<?php
function prin... |
I have wrote few function that grab the values from a form page and pass them to PHP
is there a way to write it better
function resultstype(form) {
var prod_dev=form.results_type.options[form.results_type.options.selectedIndex].value;
self.location='dd.php?pd=' + prod_dev;
}
function stype(form)
{
var prod_dev=form.... |
In my application I am attempting to queue outgoing messages by the following rules
By default they should be sent no less than messageDelay apart
Some messages can be sent immediately, completely bypassing all queued messages
Additionally, some immediately sent messages can reset the waiting time of queued messages
... |
As an extension to this post, I've created this class/script to handle multi-dimensional Menus whose data is stored in a DB. I need some feedback and new ideas.
Pastebin
<?php
/*
* Author: Carlos Arturo Alaniz
* Last Modified Date: 06/19/2013
* Languages: PHP/HTML/HTML
*
* Description:
* This class and script c... |
I'm currently developing a music website using OOP PHP and I'm trying to correctly implement the Model View Controller pattern.
I am creating this website from scratch so I would like to avoid answers suggesting I use frameworks such CakePHP etc please.
Here are simplified snippets of the files I'm using to generate a ... |
I have built a 3D matrix class in C++, mainly for data I/O, for a project I am working on. The code works ok, but I would like you to help me improve it.
Are there any bad programming practices I am doing?
Is there any code that could be simplified?
Is there something that would give me fastest access to the data stor... |
We have orange rounded buttons as a standard on our site. For our purposes, we switched everything over to use an anchor tag, instead of input type=button. The exception to this was the File Upload Control. For security reasons, you can't write your own, and since buttons in IE can't be rounded with pure CSS, I decided... |
I often need to loop through a list of items and need both the index position, and the item itself:
set names {John Paul George Ringo}
set i 0
foreach name $names {
puts "$i - $name"
incr i
}
Output:
0 - John
1 - Paul
2 - George
3 - Ringo
Since I frequently do this, I decided to implement my own loop and c... |
After a long search of simple php-jquery script from which i can pick the concept from,i gave up.The scripts i found were not very clear so i decided to make my own.This is the repo https://github.com/thiswolf/php-jquery-pagination
My code is only three file, index.php,my html file and ajax code,my dbconnection file to... |
I have
public static class TupleExtensions {
public static IEnumerable<T> SelectMany<T>(this IEnumerable<Tuple<T, T>> te)
{
foreach (var t in te)
{
yield return t.Item1;
yield return t.Item2;
}
}
public static IEnumerable<T> SelectMany<T, U>(this IEnume... |
This service object allows users without a session to create a comment, and register OR login at the same time.
If a user is signed out he must enter an email and a password along with the comment.
The service checks if a user exists using the email, then attempts to authenticate the user. Otherwise, it creates a new u... |
I have come across the following piece of code
if (Region.Current == Region.EU)
{
return RegionalPriceLN;
}
else if (Region.Current == Region.NY)
{
return RegionalPriceNY;
}
else if (Region.Current == Region.HK)
{
return RegionalPriceHK;
}
else if (Region.Current =... |
I am new to learning Repository Pattern. I am developing a site in MVC 4 (I'm new to it as well).
The way I am using Repository pattern as follows:
I created IRepository<T> interface as follows:
public interface IRepository<T>
{
void Insert(T entity);
void Delete(T entity);
IQueryable<T> Search... |
I wrote the following code to take the heading of an object, and determine which direction (x,y) it needs to move to be heading forward in a 2D plane. I have debugged the code and know that it functions as expected, but as far as readability/maintainability is concerned, I feel like it could be better. Thoughts/opinion... |
The rules for this script are simple:
If geocode is hit, then just geocode
If geocode and submit is hit, then geocode and then submit
If an autosuggest link is hit, then geocode instantly
In this case, do not re-geocode later when the button is hit
This is my code, based on help and advice from here:
http://jsfiddle... |
In the case that Type is not an option, data must exist so I just use an assert to clarify and throw an exception if data is missing. Is there a better way to do this? I think in Java this would be acceptable but I know the scala crowd tends to have a different idea of what idiomatic use of the language is.
private def... |
For my classes, I had to finish this task:
Directory's disk usage list
For indicated directory print a list of files and subdirectories in
descending order according to their total disk usage. Disk usage of a
simple file is equivalent to its size, for a subdirectory - a sum of
the sizes of all files in its files... |
We are beginning to learn Node.js and we are not always sure if we do it the right way. We have a strong object oriented background so the adoption is not always easy. Right now we implemented a factory method, but we are not completely sure if our approach is good.
Factory Method:
var fs = require('fs');
module.expo... |
I have these classes that have a boilerplate way of initialization. So, instead of writing it each time, I wrote a class called MockUtil.java, and I put the boilerplate mocks in there.
MockUtil has static variables and methods which can be called to do the mocking for the test classes. So, when writing a new test class... |
I'm going to implement something like the Unity3D component model for my C++ game engine. Please, review my draft of the Component base class:
class Component
{
public:
template<class T>
static T* create(void)
{
if (Type<T>::id == 0)
Type<T>::id = ++_idCounter;
T* component = ne... |
This is the console program that I've written in C++. It's a game where you have to guess a randomly picked number within the range 0-200. I just took a look at syntax and how to get started with C++ and VS and I was able to write this game almost immediately, but tweaking and improving it took me some time. I have a l... |
It works and does what is supposed what to do btw.
<?php
ob_start();
session_start();
include("php/connect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Welc... |
I am trying to make a textbox which filters user input to match specified type, so I can discard some of my validation logic.
For example, if I specify ushort I want my textbox to only accept text changes which result in a valid ushort value and nothing else.
This is what I've ended up with:
public abstract class Custo... |
I am working on a project that needs algebra operations. I have coded a Matrix class (only needed 4x4 matrix), and a Vector4 class. The classes working fine, but I would know if there are some bad practices that I use, and want you to help me improve this classes. Last time I encountered some problem when wanted to cod... |
This Lua code runs in redis. It iterates over some JSON docs, and applies some logic based on the user (if any) making the request. I'm sure there's a lot I can improve here.
local function iterAll(limit)
local start = 0
local stop = limit-1
local ids = redis.call('zrevrange', 'questions-by-latest', start, stop)
... |
I have this code:
if(listObj.Any(x => x.id < 0))
{
foreach(ModelClass item in listObj)
{
if(item.id < 0)
{
// code to create a new Obj in the database
}
}
}
But, should I use like this?
foreach(ModelClass item in listObj)
{
if(item.id < 0)
{
// code to cr... |
This is one of my first steps with GUI. I've tried an implementation of Conway's Game of Life with TkInter.
I would appreciate any opinions about my code, especially about the separation of GUI and logic.
import Tkinter as tk
from copy import deepcopy
from random import randrange
def random_fields(width):
"""
... |
I am currently trying to improve on a query that is being used to build a view. The query is in PL/SQL, in an Oracle database. There are 3 different types of reports (100,200, and 300) that are generated at each building. We track the consecutive years that each report is generated, and based on the combination of (1) ... |
A company sells iPods online. There are 100 stocks maintained at
Argentina and Brazil. A single iPod costs $100 in Brazil and $50 in
Argentina. The cost of exporting stocks from one country to the other
will cost $400 per 10 blocks. The transportation is always done in the
multiples of 10. Calculate the minim... |
I'm still learning jQuery and am wondering if there are other ways to put .each() inside another .each() function:
JavaScript:
$("ul").each(function(index){
$("#uid" + index + " li").each(function(listItemIndex){
var listItemWidth = $(this).width();
var listItemPosition = listItemIndex * listItemW... |
I was doing this particular problem AIBOHP and used a dp approach based on checking the ends of a substring of length i starting from 1. Although my time complexity is fine at O(n^2) but space is taking too much because of which I am getting RTE if I am declaring it dynamically or TLE if I am declaring it as global sta... |
I have written a Custom Log4J Appender which is responsible for sending the log message to a third party service asynchronously. It is expected to be called every millisecond.
I ran FindBugs on this code, it didn't report anything unusual. But before releasing this code to production, how can I know if this code has an... |
Write a program that lets users keep track of the last time they talked to each of their friends. Users should be able to add new friends (as many as they want!) and store the number of days ago that they last talked to each friend. Let users update this value (but don't let them put in bogus numbers like negative valu... |
I'm a photographer doing many backups. Over the years I found myself with a lot of hard drives. Now I bought a NAS and copied all my pictures on one 3TB RAID 1 using rsync. According to my script, about 1TB of those files are duplicates. That comes from doing multiple backups before deleting files on my laptop and bein... |
The code works but I want to split it into functions and make it more reusable. The way it is now, the code is not reusable. I want the parts which replaces the query string and the part that populates with the number of items to be reusable for other classes, so ideally I want to make'em functions but then I suppose I... |
I'm using JPA 2.0, Mojarra 2.1.9 and its component library Primefaces 3.5. I have a table in MySQL database named state_table with three columns.
state_id (BigInt)
state_name (Varchar)
country_id (BigInt)
state_id is a auto-generated primary key and country_id is a foreign key that references a primary key of the cou... |
I was asking if the following code has a correct semantically markup, or can it better, and so yes, how:
<!-- Start container website -->
<header id="header">
<div class="container_12">
<div class="grid_12">
<a href="#" id="logo"><img src="images/logo.png" alt="Logo"></a>
... |
I recently created the following code, which is supposed to implement a Pong variation for one player. How can I improve or optimize my code?
Pong class:
import javax.swing.JFrame;
public class Pong extends JFrame {
private static final int HEIGHT = 500, WIDTH = 900;
public Pong() {
super("Pong");
... |
I'm looking for some opinions on this bit of code that I wrote and if there are any ways it can be improved.
The scripts aim is to run the function runme() every 60 seconds with a random interval anywhere between -20 seconds to +40 seconds so it could run randomly anywhere between 40 seconds and 100 seconds.
import sch... |
I implemented a strongly connected graph code in C++.
matrix_graph.h
#pragma once
#include "stdafx.h"
class matrix_graph
{
private:
int** v;
int vertexes;
public:
matrix_graph(int**, int);
~matrix_graph(void);
void reverse();
int get_max_vertexes();
bool is_connected(int i,int j);
};
matri... |
First of all, I'm really new to SFML and making GUIs. This is my first real program using this.
Right now, when I click outside the window when the program is first run, the first piece is placed in the top left corner without clicking that square. It works as I want it to every time after that, with an error message... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.