```
WEEK04: computer graphics, using objects
----------------------------------------
W: more graphics...

LAB4: due next week
QUIZ 2 this Friday

USE OF random LIBRARY/MODULE:

>>> from random import *
>>> randrange(1,10)
2
>>> randrange(1,10)
4
>>> randrange(1,10)
3
>>> randrange(1,10)
3
>>> randrange(1,10)
6

>>> L = ["pony","horse","unicorn"]
>>> choice(L)
'horse'
>>> choice(L)
'pony'
>>> choice(L)
'unicorn'
>>> choice(L)
'pony'
>>> choice(L)
'pony'

OBJECT TERMINOLOGY:

object: a combination of data and methods, all in one thing
method: functions to access or modify the object data
constructor: special function called when object is created
instance: constructed objects (ex: c = Circle(p,20)...c is an
instance of the Circle class)

WHERE WE ARE HEADING...OBJECTS (everything in python is an object)

\$ cat nba.txt
#
# name, total points scored, number of games played
#
Lebron James, 697, 23
Kevin Durant, 570, 20
Kobe Bryant, 360, 12
Kevin Garnett, 384, 20

Wouldn't it be nice to store all data about each player in
an NBAPlayer object, including any functions we plan to use
on that object?

For example:

# create LJ object, given name, points, games played
LJ = NBAPlayer("Lebron James", 697, 23)
# update object with addGame method
LJ.addGame(35)   # he scored 35 points in this game
print LJ         # print updated object
Lebron James is averaging 30.5 points/game in 24 games

REVIEW FROM LAST TIME:

- see /home/jk/inclass/xmark.py for an example

- note use of these:

clone()
move()
getMouse()
getX()
getY()
setText()

- figure out algorithm to draw a bullseye/target, like this:

How do we draw one circle on top of another?
How do we draw one red circle, then one white, then red, etc?

With just 4 circles you could do this manually. If I asked
you to change the target to have 20 circles, how would you
alternate colors??

nrings = 5
r = width*0.5
dr = r / nrings
cp = Point(___, ___)

for i in range(nrings):
c = Circle(cp, r)
# make the ring color alternate
if i % 2 == 0:       # i is even
c.setFill("red")
else:                # i is odd
c.setFill("white")
c.draw(w)
r = r - dr

GETTING AND USING MOUSE CLICKS:

\$ python constellation.py
How many stars? 7
Constellation name: Orion

(then program waits for 7 mouse clicks, and draws a star
at the location of each click)

Program should also tell user how many clicks are left...

```