Remember the chair object we made earlier? We are going to write some pseudocode where you will write the properties of a chair. You will then call the method to create a chair.
Skillcrush gives students the values of the parameters they need to use to run the method. In this challenge, you want to create a wooden, 4 legged chair.
First, let’s create our function. Put a function keyword then name your function. I’m going to name this function assemble chair.
On the next line, put the stop keyword to end your function. In this example, I’m going to use stop function since this is another way of telling the computer in pseudocode to end the function. Next, we are going to concentrate on the instructions for this method.
Underneath your function name, you are going to write the inputs the user is going to give the computer. In this method, you will need users to input the chair back, chair seat, and chair legs. So put an input keyword then list these parameters after it.
Now we are going to start assembling the chair. Underneath the inputs, we are going to start by attaching the chair back to the seat. So the first instruction is just attaching the back to the chair.
Next, the legs will need to be attached to the seat. The second step will be attaching the legs to the seat. All that is left to do is show the finished chair. Before the stop keyword, you are going to use the output keyword to tell the computer to show the finished chair. After the output keyword will be the assembled chair.
After our function, we are going to call our method. So we will put run function to tell the computer we are going to run our method. Then you will want to put the method name.
Now we have to give the computer our inputs. So put with inputs keyword then list the values for the chair back, chair seat, and chair legs. These values will be wooden back, wooden seat, and 4 wooden legs.
That’s a wrap on your method! We just finished the challenge and completed all the objectives Skillcrush has given us. Here’s a look at how your pseudocode might look on. Make sure you indent your method instructions.
FUNCTION assemble chair
INPUT chair back, chair seat, and chair legs
Attach the back to the seat
Attach the legs to the seat
OUTPUT assembled chair
RUN FUNCTION assemble chair WITH INPUTS wooden back, wooden seat, and 4 wooden legs