CodeNewbie Community 🌱

Sarah Dye
Sarah Dye

Posted on • Edited on

How to Define Properties of a Chair

Before we start working on the magic 8-ball project, let’s take a minute to practice creating an object and some properties. In the first challenge of this lesson, we are going to create an object in pseudocode for a chair. Making a chair may sound a bit strange, but it is a great way to practice creating objects since they have many properties and the properties values will differ for every chair.

Don’t forget the abstraction principle. We want to focus on the important properties that are essential to creating a chair.

Solution

Now let’s create a chair! First, let’s use the object keyword to let the computer know we are creating an object. We are going to name our object chair.

Next, we are going to create the chair properties. There are three properties in this challenge. So three lines of pseudocode will be for every property.

In this example, the three properties you will need are the back, seat, and legs. For every property, you will use the property keyword before each of the property names. Don’t forget to indent each of the properties underneath the object line we wrote earlier.

Finished Pseudocode

Below is an example of what the pseudocode for this challenge might look like. You can add more properties to the chair if you like. The goal here is to practice using the keywords just right.

OBJECT chair 
PROPERTY back
PROPERTY seat
PROPERTY legs
Enter fullscreen mode Exit fullscreen mode

This post was originally published on July 5, 2021 on DEV. I made minor changes to the original post for CodeNewbie.

Top comments (1)

Collapse
 
manslie3 profile image
manslie3

Leather doesn't trap dust, pet dander, or other allergens as easily as fabric buy here, making it a suitable option for those with allergies.