24: OOP Game

You are now going to complete a reworking of your game into an OOP version. What I've done is created the structure for you using classes and objects, but I've left blank what goes in each room. Your job is to take this and fill in your code from your first game but keep the structure and make it all work with what I have.

You will need to study this code very carefully as it is convoluted on purpose. I am making it more convoluted that it needs to be so that you can have some practice studying code like this. Then in the video for this exercise I do something called "re-factoring". This is where I take a code that is not very good and attempt to improve it by redesigning it or reworking it to be better.

I recommend that you take this code very slowly and work it in chunks. Do not type all of this in in one giant go expecting it to work the first time. Nobody who is a working professional programmer writes mountains of code in one shot and expects it to work. The majority of programmers I know right there code in tiny chunks and confirm that each little chunk works as they code. If you are not sure what I'm talking about then watch the video where I demonstrate this.

The Code

Learn JavaScript Today

Register today for the Beginner Basics course and get the new releases by just paying the difference. There's also special discounts for existing customers when new courses are released.

Still Not Sure? Check out more curriculum!