Purchase Solution

Design a Program that Models a Worm's Behavior

Not what you're looking for?

Ask Custom Question

Design a program using pseudocode that models the worm's behavior in the following scenario:

A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple.

Purchase this Solution

Solution Summary

This solution provides guidelines on designing a program using pseudocode to depict a worm's movement.

Solution Preview

I used the Object-Oriented Design (OOD) for the behavior of the worm. Defining a class Worm, it has two arguments: the length of the worm itself and the distance from the apple. It also has two behaviors: move and enter. Here is the pseudocode with comments.

class Worm { // Define the class of Worm
var length; // Define the variable length to be the length of the worm
var distance; // Define ...

Purchase this Solution


Free BrainMass Quizzes
Basic Networking Questions

This quiz consists of some basic networking questions.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.