Skills Expanded

Building a Simple Shopping Game with Object-oriented JavaScript

What you'll learn

In this Project you will build a simple, interactive, terminal based Shopping Game called Shopping Master, using Object-oriented JavaScript. Throughout this project you will learn all about the Object-oriented features of JavaScript and their practical usages.

Table of contents

Setup
10m
  • Set up your local environment for this project. We'll walk you through everything you need to know, including how to install and configure your environment to be able to complete all of the tasks.
Defining Objects and Classes
1h
  • In this module we will start implementing the Shopping Master game by defining the objects and classes required for the game. We will gradually add on to the script to make use of them to implement our game in the next modules. By the end of this module, you'll have defined all the objects and classes along with their properties, getters and setters, other methods and established the links between classes (i.e. Inheritance).
Loading Master Data
1h
  • In this module, we will populate the master data required for the Shopping Master game in to an array. We will use the `Product()` & MagicProduct() object types to create sample products using the given master data map. By the end of this module, you'll have loaded the `Product` & `MagicProduct` data required for the game to function.
Locate a Product
30m
  • In this module we are going to complete two functions, findProductById() and generateProductId(). These two functions will be used in the next step of the Shopping Master game for retrieving a specific product from the list of available products.
Implementing Points Calculation
1h
  • In this module we will implement the player's point calculation logic of the Shopping Master game. To do so we need to complete the three functions: calculateBill(), findPointsForExpDate() and claculatePoints().
Implementing the Shopping Functionality
1h
  • In this module we will implement the shopping functionality which will be the main part of the game. For this we need to add a few lines of code inside init() function and shop() function. By the end of this module you'll have implemented the initialization function of the game by initializing the player object by assigning values to its properties. In addition, the shopping functionality is implemented by offering products to the player, setting the item count and the player's score as the player continues to play the game and finally the player's status based on the points earned.
Implementing Game Exit Functionality
30m
  • In this final module, we will implement the game exit functionality by completing rateAndExit(), exitLost() and exitWon() functions. By the end of this module you'll have fully implemented the Shopping Master game and you should simply be able to run the game once you uncomment the code snippet right above the main() function.

About the author

Buddhini is an EdTech Enabler/ Author / Instructor / Lecturer / Trainer and a Senior Java Engineer who is passionate about learning and exploring new technology as well as sharing her knowledge with others in the most learner friendly and effective manner. Buddhini always looks for challenging work and opportunities to learn and develop herself as well as to teach what she knows, to other technology enthusiasts. With her 19 years of experience in the IT/Software Development industry, Buddhini h... more

Ready to upskill? Get started