Computer Science 15-100 (Sections T & U), Fall 2007
Class Notes, Day 5: Tue 11-Sep-2007
Logistics
- Schedule
- Quiz1 today.
- Hw2 deadline moved to Friday.
Submit email copy to your CA by 8:30am, physical copy at recitation.
See my email about this for more details.
- No class on Thursday!
- Recitation Friday: review quiz1 + hw2 solutions + help on hw3
- Quiz2 on Tuesday (next class!): covers material through hw2 and ch2,
including all the reading and class notes
- From today: Graphics will be covered on Quiz2, but ch3
material will not.
- Reading for next lecture
- L&L Chapter 3: Using Classes and Objects
Sections
3.1 - 3.5
Topic Outline:
- Hw2.java
- BasicGraphics.java and
BasicGraphicsDemo1.java
- Paint both filled and unfilled shapes
- Paint various shapes:
- rectangle
- oval
- polygon (triangle, pentagon, etc)
- line
- Paint both thin and thick lines
- Paint custom colors
- Use trig to position a shape
- Use variables to make shapes change properly when the window is resized.
- Use variables to draw variants of the same shape by reusing or sharing
code.
END OF Hw2 and Quiz 2 MATERIAL
- Initial Style Guidelines
Style Counts!
Starting with hw3, and increasingly on each subsequent homework.
- Naming
Use well-named variables. Single-letter variable names are only
acceptable in special situations, like "x" and "y" for coordinates. In
general, variable names should be whole words (like "left") or even multiple
words (like "rectangleLeft", which may hold the left side of a rectangle).
- Capitalization
Capitalize variables in lowerMixedCase and classes in UpperMixedCase, as
shown.
- No "magic numbers"
Any number that is not -1, 0, 1, or 2 is a magic number and should be stored
in a well-named variable for clarity and generality.
- Formatting
Indent and space your programs like the sample code provided (more on this
later).
- Commenting
Provide clear and concise comments where needed to clarify your code.
Never provide obvious comments (like "add one to x" on a line that reads
"x++;"). Your comments should not say what the code does (your code
says that!), but why it does it that way or some other clarifying text.
- UI
Provide a clear and concise user interface (UI), whether in a console or
a GUI (graphical user interface). Unless otherwise directed, provide
prompts for input, clear explanatory text for output, and meaningful error
messages.
- More later....
- Quiz 1. Good luck!
Carpe diem!