3 1/23: Fundamentals + Pong
Due: 1/23.
Language: class/0.
In this assignment, you will practice designing solutions to several small problems. Then you’ll build another classic computer game: Pong.
 Here is an example of a mobile:

           
 
60 
blue          
 
 40
      red
 
10 
green 5
red
The number of dashes in the struts and lines represents their length, while the numbers and colors represent the weight and color of hanging objects.
Design data definitions for representing hanging mobiles. Make an example of mobile data that represents the example given above.
Design the method totalweight that computes the total weight of a mobile. The weight of the lines and struts is given by their lengths (a strut of length n has weight n).
Design the method height that computes the height of the mobile. The example has height 7.
Here is a class diagram for employees. Develop data and class definitions for employees.
Design the method countsubs that computes the total number of subordinates of this employee.
Design the method fullunit that collects all of the subordinates of this employee. Hint: you may find it useful to add an append method to the ILoE interface (and implement it).
Design the method haspeon? that determines if this employee has a peon with the given name (a string).
A football game consists of a series of Posessions. Each Posession starts at a location on the field (a yard from 0 to 100), ends at a specific location on the field, either with a score (of either 3 or 7 points), or a kick to the other team, causing them to start at a new location on the field.
Design a data defintion for football games. Then design the method totaloffense, which records the number of yards gained by the team that started with the ball first. Design the method totalscore, which records the total number of points scored by both teams.
Here is a data definition for a time of day:
; A Time is a (new time% Hours Mins) ; where Hours is an Integer in [0,24) ; and Mins is an Integer in [0,60) Develop a class definition for time%. Design the method >minutes which converts this time to the number of minutes since midnight.
Here is a data definition for an event:
; An Event is a (new event% String Time Time) ; Interp: an event with a name and a start and end time. Develop a class definition for event%. Design the method duration which computes the duration of this event in minutes. Design the method endsbefore? which determines if this events ends before a given event starts. Design the method overlap? which determines whether this event overlaps with a given event.
Here is a data definition for a schedule:
; A Schedule is one of: ;  (new noevent%) ;  (new consevent% Event Schedule) Design the method good?, which determines if the events in this schedule are in order and do not overlap. Design the method scheduledtime, which computes the total time in minutes scheduled in this schedule. You may assume this schedule is good for scheduledtime. Design the method freetime, which computes a schedule of events named "Free time" that are all times not scheduled in this schedule. You may assume this schedule is good for freetime.
Develop data and class definitions for representing lists of numbers. Design the reverse method that consumes no arguments and produces the list of this list’s elements in reverse order. You should design the method using a helper method with an accumulator.
Note: you may not use lists from last semester, i.e. those constructed with cons and empty.
Revisit your solution to freetime. Did you use an accumulator desgin? (You probably should have.) If you didn’t, redesign the program with an accumulator.
Here is a data defintion for a Shape:
; A Shape is one of: ;  (new circle% radius) ;  (new rectangle% width height) Define the appropriate classes, and design the methods size, which computes the area of a shape, and draw, which takes a Color and produces and image of the shape in that color.
Extend your data defintion to support overlayed shapes, and add an overlay method to the interface that all Shapes support.
Now extend your classes to support the underlay method. Can you write this method just once?
 Design a representation for a Population. This consists of children, adults, and retired people. In this society, everyone becomes an adult at 25, retires at 65, and dies at 90. Then, design the following methods:
ageall, which makes everyone a year older,
maxage, which computes the age of the oldest member,
halfworking, which ages the population until there are half as many adults as there were to start with.
Design a representation for simple organic molecules. An organic molecule is either a carbon atom, or a carbon atom connected to additional carbon atoms via bonds. A connection between two carbon atoms can be either a single, double, or triple bond. The total number of bonds attached to a single carbon atom is at most 4.
Define butane as an example, which is just 4 carbons in a line, with all single bonds. You can see a diagram of butane here.
Design the method countcarbons, which starting from a carbon atom, counts all the carbon atoms connected to it (including the starting atom).
Design the method valid?, which determines if every attached carbon atom has at most 4 bonds.
It turns out that all of the gaps, i.e. the possible bonds that aren’t connected to another carbon atom, are actually connected to hydrogen atoms. Design the method counthydrogens which counts the number of hydrogen atoms reachable starting from a carbon atom (i.e., counts all of the gaps).
Pong!
Design and implement a twoplayer version of the classic Pong game. You can see Pong in action in this video of the original game or this online version.
The important elements of the game are the following:
Two paddles, which move up and down but not off the screen. One paddle should be controlled by the w and s keys, and the other by the up and down keys.
A ball, which bounces off the top and bottom walls and off the paddles.
A winning condition, when the ball reaches either side wall.
A score, for each player, which counts the times the ball hit the other side wall.
In other words, it should look a lot like the original Pong game in the video. You do not need to implement any embellishments, such as varying bounce angles, faster speeds, or fancier graphics.