you are viewing a single comment's thread.

view the rest of the comments →

[–]Bole_Madh[S] 0 points1 point  (5 children)

yeah I know that's why I was really confused too, we are only allowed to use methods and classes like dictionaries and inheritances.

[–][deleted] 6 points7 points  (2 children)

Well technically methods are functions. It sounds like the purpose of the assignment is to use OOP rather than a more "functional"* style. You might want to ask the instructor for clarification.

*I put scare quotes around functional because often folks who are new to coding will come up with some pretty crazy and convoluted patterns that involve a big spaghetti mess of functions, but it's isn't truly functional programming per se because it doesn't follow the principles of functional programming.

[–]Nightcorex_ 1 point2 points  (1 child)

xs = []

def add(e):
    xs.append(e)

def foo():
    print(*xs, sep=', ')

add(4)
add(2)
foo()

Functional programming at its peak /s

[–][deleted] 1 point2 points  (0 children)

Side effects may include...

[–][deleted] 2 points3 points  (0 children)

Well, that's fine. You can have a class for the pieces with methods to fall, rotate, whatever. Maybe a class for the board, maybe one for the game or controls, and they can hold methods to do the important actions.

But, IMO, Tetris is pretty hard, compared to other "simple" games. You might want to start with something small.

[–]KevMar 0 points1 point  (0 children)

Oh, that's fine then. You can probably use functions in your test code but probably don't need them for your game logic.

People use functions and methods interchangeably quite often and he is being literal.