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 a Senior Java Engineer/ Author/ Instructor/ Lecturer & Trainer having over 19 years of industry experience working with multi-national Software Companies. She has worked in many mission-critical projects in domains such as Supply Chain Management, POS & Electronic Content Management, mainly based on the Java & Java EE tech stack. As a result of her love for teaching & mentoring, at present she is an Author/Instructor for some of the leading online learning platforms including Plurals... more

Ready to upskill? Get started