New answers tagged

2

This answer is focused on one very specific part of this program. Let's take a look at the Actor class. Specifically, these two methods: def lost_bet(self): raise NotImplementedError("Subclass must inherit this abstract method") def won_bet(self): raise NotImplementedError("Subclass must inherit this abstract method") Now lets list how many ...


4

There is room for improvement in your code, I'll give a few pointers of things that stand out to me. DRY (Don't Repeat Yourself) There is a lot of copied and pasted code in your work. It makes it harder to read and much harder to maintain. To initialize the board, you manually put in 49 instances of a class with some parameters changing. What if you want ...


-2

Handle the Aces! (That's my only problem, I got a 22 at start)


1

Avoid many duplicate calculations. The code will be shorter and easy to read. i.e. in towerMoves void towerMoves(){ for(int dir = -1; dir < 2; dir+=2){ for(int tx = x+dir; tx>=0 && tx<=7; tx+=dir) { if(board[y][tx] != 0) { if(blackWhite[y][tx] != color) { moves[y][tx] = 3; ...


2

Almost six years later... I discovered a bug in the code below: @Override public boolean isAllowedPlay(TTBase tile) { TTBase area = tile.getParent(); if (area == null) return false; TTBase game = tile.getParent().getParent(); if (!tile.getWonBy().equals(TTPlayer.NONE)) return false; if (area.getWonBy().isExactlyOnePlayer(...


6

It's hard to make small tweaks to this code to make it do what you want, so I'm going to give some pointers on how to do a wholesale rewrite. Before you can write a card game, you need to write a data model for a deck of cards. Picking the right data model makes everything else easy (part of why your program was hard to write and is hard to fix that the ...


Top 50 recent answers are included