Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

There are several things you can do to improve this code. First of all the code above isn't a valid C++ code. To run it you need to add: #include <string> #include <iostream> #include <Windows.h> int main() { ... // your code posted above } Please next time you ask a question post the full code. Then your Menu: std::cout << "...


5

Style The overall style is good and mostly follows the official style guide. Since you have a lot of code and the scope will likely expand even more, I would highly recommend using an automatic style checking tool like pylint, flake8, or the like. There are a lot of Python IDEs which integrate nicely with those style checkers (Visual Studio Code, PyCharm, ...


2

There are a lot of improvements that had to be made, the most important for you to understand are arrays, especially 2D arrays; for loops; and ternary operators. using System.Threading; using static System.Console; namespace Test1 { class Program { const int boardWidth = 7; const int boardHeight = 10; static bool[,] lines = ...


-1

import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class YatzyUI { public static void main(String[] args) { System.out.println("Enter the names of the players separated by comma,"); Scanner sc = new Scanner(System.in); String names = sc.next(); String[] ...


0

This is just the main method that controls the game. All the interesting code is missing. Instead of reading the names of a fixed number of players and storing the players to two distinct method variables, read a name and create a player into the list in a loop, until the user provides an empty line to denote en of input. Variable score is unnecessary. ...


1

Unfortunately nobody has reviewed this code since it was posted. Are you still using this code? It doesn't appear that you have been active much here in recent years so I might guess not. The functions ailogic.imaginaryMoveThem() and ailogic.imaginaryMoveMe() look very redundant. Perhaps it would be simpler to abstract out the common code to a separate ...


3

Composition over inheritance. You have a base class GameObject which only does collision and bounding box type stuff. There is no need for it to be a base class that you inherit from. Make it a member variable instead and access it when you need to. Adding gravity to the ball and moving the platform in response to keyboard doesn't need virtual functions.


2

Steve. Below are some thoughts on what you've provided. With respect, this code is really not at a state where it's reviewable per the guidelines in Code Review - it should be complete and working correctly. I understand why you're asking for a review, but maybe try to get the code further along? Class names should be CamelCase, so MapSystem2 would be ...


1

From a quick review; Comments should be in English Commented code should be removed a is not a great variable name, allowed would be better If map[x][y] really can only contain 0 or 1, then you might as well just a = map[x][y] The code is not consistently indented You should call check=tileCheck only once before if ("north".equals(d)) You should code for ...


3

I only got to the core classes, not the game implementation. Hopefully this will give you something to think about. General Classes that are not designed for extension should be explicitly marked as final. Variables that will not be reassigned should also be marked as final. This makes it easier for readers of your code. I'm assuming this API is designed ...


1

The way to move things is extremely restricted. Instead of marking entities moveable (mobile?), encapsulate the behaviour of mobility behind an interface and inject a suitable implementation to each entity. When the time comes to move an entity, whoever is responsible for triggering it, fetch the mobility implementation from the entity and have it perform ...


3

Disclosure: I know that it has been ~6 days since Mangus's answer was submitted and you have already updated your code. However, I still have suggestions that will hopefully help. Your Questions Can you tell me how to optimize more and what are the missing things? See the suggestions below for optimizing code. I am not really sure what is "missing"... ...


-1

This script is pretty good. But I recommend using a Queue instead of a List. Try this custom class Object Pooling, Custom pool classs


2

While your code seems to work, the next step should be separating the different responsibilities of your code. As far as I can see, there are three: You have to ask the user for an index. It needs to be an integer in the range [-1, len(s)). You have to ask them for a replacement character. It must be exactly one lower case character. You need to actually ...


1

Performance You create a new Scanner for every guess. this is unnecessary. the same scanner can be used to read all user input. the scanner should be closed only at the end of the program. and if you adopt that, you can also use Java 7 try-with-resources feature. it is a safe(r) way to open and process external resources. JDK library features in order to ...


5

Note, some of these require a build process the iife should be added in the build process, it's distracting The code doesn't expose anything. It's untestable. var should be let or const You can use arrow functions to turn some of the functions into one liners Inconsistent formatting - I recommend getting a linter setApplicationView - Should probably be ...


2

Foreword Your code is quite decent. However, I did make a general outline of how I would probably implement a Board to improve readability. Don't feel the need to take my suggestion. The major changes I made to the code is CSS and HTML restructuring. Additionally, I made modifications to accommodate different window sizes better. The updated code is at ...


1

This code makes great use of the keywords let and const where appropriate. Some of the functions are a little on the long side, so those could potentially be split up into smaller functions. The repeated calls to functions like this.load.image could be done in a loop over arrays if pre-defined arrays were setup. Did you consider using element references, ...


1

Nice work. I got pretty distracted playing a few games before starting the review. Your 'Tic-Tac' display should be put inside a method, and called on the constructor. This way you're explicitly stating when the title will be printed, rather than leaving it up to the JVM. (The static block will be executed the first time the class is referenced). I believe ...


0

Style If you know the term 'un-Pythonic' you should also know the term PEP-8. Before doing anything else, pep8-ify your code. That means: Use snake_case for function and variable names. Use PascalCase for class names. Use ALL_CAPS for constants. It also means: Put your code in functions or classes Use an if __name__ == '__main__': guard to invoke your ...


Top 50 recent answers are included