LMICSE: Lego Mindstorms in Computer Science Education

Site Map | Contact Us
Project Overview | Staff | Grant Information
Short Workshops | Primary Workshops
CS 1 | Data Str. & Algo. | Prog. Languages | Architecture | Intelligent Sys. | Operating Sys. | Net-centric
Ada | C | C++ | Java | Lisp

Lab 2: Lists

small logo

Use of Lists

Lists are another structure geared towards organizing sets of data. The underlying idea behind a list is the basic idea that the items in the set will have some part that is comparable. Thus these lists can be unordered(items are in the list with no particular arrangement) or ordered (the items are added in a particular fashion), both of which have their uses.

Prerequisite Knowledge

A basic understanding of how to control the Turtle's movements as well as using data structures and other fundamentals in java.

Materials

Standard Turtle robot with bump sensors.

Task One

Design a program that will use the provided DanceMove class to do 3 random dance moves. The DanceMove object is a fairly straight forward one that when its constructor is called creates a random move that can then be assigned to either a comparable object variable or a DanceMove variable. Also provided are methods for doing a move, comparing two moves, getting and setting a quality in the form of an integer, and an equals command for determining if two objects are equal.

Task Two

Now redesign your code to create and do ten moves that after being done the first time get put into a list structure that can be traversed linearly forwards. To do this an underlying structure of a vector is recommended due to its infinite capacity. Also needed will be typical methods pertaining to a list such as add and getNext (for more information see the UML diagram at the bottom).

Task Three

Finally make your program do a move, get a quality input from the user using the bump sensors, then store that move into the list using the quality as the key to determine the appropriate location in the list for that move(your add method will need to be modified). The moves should be stored in some order that allows them to be easily called according to which are the best. Then after the robot has done and rated 10 moves it will sound a beep sequence signaling the completion of phase one and then wait for the user to input how many of the top rated moves to perform again in best-to-worst order.

UML Class Diagram

Your task 2 should have a similar UML diagram to:

Additional Problem

Create your program so that the user inputs how many moves to do initially, each moves rating, whether to do worst or best moves, and how many moves to do over again.

Conclusion

In this lab, you learned the following:

  • How to construct your own list structure
  • How to utilize lists to order sets of data