Hiding details.
A series of items.
Each item consists of a question and an expected answer.
Flashcards: question on the front; answer on the back.
Study list: questions on one side of the page; answers on the other.
A quiz itself: shows the questions; leaves blanks for students to fill with answer.
In Snap! we have a few ways of representing data.
For simple data we’ve used numbers, text, and true/false values.
How can we represent a collection of multiple pieces of data in Snap!?

A data type is just a way of storing some data.
Numbers, text, and Booleans (true/false) are all examples of data types.
They are built into snap so from our point of view they are fairly concrete which is the opposite of abstract.
In reality they are an abstraction provided by Snap! But we can treat them as fundamental building blocks.


Here’s a simple quiz with just two questions.

This works but we’re talking about lists rather than questions and answers.
And it gets even worse when we want to get the parts out:


To understand code written like this we need to remember which position holds the question and which holds the answer.
Suppose we had a block for creating quiz items:

And two blocks for getting the parts out:


These blocks provide an abstraction that lets us deal with quiz items without having to know how they are stored.
Together they define an Abstract Data Type or ADT for representing quiz items.
An abstract data type is a data type that is defined purely in terms of what you can do with it without having to know how it is represented.
For the purposes of this lab there are two parts to an abstract data type: constructors and selectors.
Constructors are blocks that construct (or make) an instance of the abstract type. In this case our constructor is the
block.
Selectors are blocks that select on part or another out of an instance of the abstract type. Our selector blocks are
and
.
The constructor

The selectors

These have to be defined so they work together.

We are just using a list to represent the quiz itself.
Do you think it would be useful to create an ADT to represent a quiz?