Back

Code Challenge Set 3

Complete any 2 of the 4 below.

divider

What This Set Is For

Everything here needs a table and a function of your own. That is deliberate: they are the two things the Create Task will ask for, and this is the last practice before you scope your own.

Iteration completes the set of three. Every challenge below has a loop doing real work, and in two of them the loop is inside your function.

Name the table and the function before you write any code, in your requirements list. What is in the table, what the function takes, and what it does with it.


This Set Is About Building Something Reusable

The gaps here are different again. The briefs are clear about what they want to see and vague about how much of it — how many, how big, how often. That is the sort of vagueness a table and a function are for.

A fragment, and what it leaves open:

From the Health Bar brief
Segments, not a solid block. It has to work at any
position and any size, and it should look different
when things are going badly.

That is a normal way for a person to describe what they want, and it is not enough to write a program from. Here is what should end up in your requirements list:

Requirements — the questions half
- How many segments? Fixed, or one per unit of health?
- What is "badly"? A quarter left? A tenth? One segment?
- Does it look different by color, by size, by flashing?
- What does an empty bar look like? What about a full one?
- What happens if health is above the maximum, or below zero?

There is no right answer to any of those. There is only a decision you made or a decision you did not notice. Two programs that answer them differently are both correct; a program whose author never thought about it is the one that goes wrong in front of somebody.


The Challenges

Pick any two.


Submit

For each of the two: the requirements list and the program folder.

The requirements list is the deliverable that is actually being read. The code is evidence you tried to satisfy your own list.

Worth 10 points, graded on completion.

Commence Challenge