CSE 8B Today

How was it? A. No sweat! B. Not too bad C. So-so D. Not so good E. Totally awful

Please do not talk about the exam with anyone outside this room until after 2pm today. (It’s impossible to make a completely different exam for the other section)

PSA3: The last element in the array “Knock” “Knock” “Who’s”

“Knock” “Knock” “Knock”

What’s the problem with the last element when counting the number of each word? How can you solve it?

Layout Managers public static void main(String[] args) { JFrame myFrame = new JFrame("This is my window"); myFrame.setSize( 300, 400 ); FlowLayout flow = new FlowLayout( FlowLayout.LEFT ); GridLayout grid = new GridLayout( 5, 6 ); myFrame.setLayout( flow ); for ( int i = 0; i < 20; i++ ) { JLabel label = new JLabel("CSE 8B"); label.setFont( new Font("Serif", Font.ITALIC, i*3 )); myFrame.add( label ); } }

Sketch (more or less) what you think this GUI will look like

A note about style… private char rc( char x, int y ) { if (!Character.isLetter(x)) return x; y = y % 26; if ( y < 0 ) y += 26; char z = (char)(x + y); if ( Character.isUpperCase(x) && z > 'Z' ) z = (char)(z - 26); if ( Character.isLowerCase(x) && z > 'z' ) z = (char)(z - 26); return z; }

What does this method do?? A. I have no idea B. I think I might know C. I am (pretty) sure I know

A note about style… private char rotateChar( char c, int rotation ) { if ( !Character.isLetter( c ) ) return c; rotation = rotation % 26; if ( rotation < 0 ) rotation += 26;

char charToReturn = (char)(c + rotation); if ( Character.isUpperCase(c) && charToReturn > 'Z' ) charToReturn = (char)(charToReturn - 26);

if ( Character.isLowerCase(c) && charToReturn > 'z' ) charToReturn = (char)(charToReturn - 26); return charToReturn; }

What does this method do?? A. I have no idea B. I think I might know C. I am (pretty) sure I know

And don’t forget your header comment!!

A note about style…

private char rotateChar( char c, int rotation ) { if ( !Character.isLetter( c ) ) meaningful variable return c; and method names rotation = rotation % 26; if ( rotation < 0 ) rotation += 26;

Proper indentation, short lines, and plenty of char charToReturn = (char)(c + rotation); whitespace if ( Character.isUpperCase(c) && charToReturn > 'Z' ) charToReturn = (char)(charToReturn - 26);

if ( Character.isLowerCase(c) && charToReturn > 'z' ) charToReturn = (char)(charToReturn - 26); return charToReturn; }

Short, targeted method

Style guidelines on the CSE8B homepage. Starting NOW (with PSA3) style matters!

A note about style… private char rotateChar( char c, int rotation ) { if ( !Character.isLetter( c ) ) meaningful variable return c; and method names rotation = rotation % 26; if ( rotation < 0 ) rotation += 26;

Proper indentation, short lines, and plenty of char charToReturn = (char)(c + rotation); whitespace if ( Character.isUpperCase(c) && charToReturn > 'Z' ) charToReturn = (char)(charToReturn - 26);

if ( Character.isLowerCase(c) && charToReturn > 'z' ) charToReturn = (char)(charToReturn - 26); return charToReturn; }

Short, targeted method

Welcome to CSE 8B!

(It's impossible to make a completely different exam for the other section). How was it? ... Style guidelines on the CSE8B homepage. Starting NOW (with PSA3) ...

473KB Sizes 1 Downloads 181 Views

Recommend Documents

No documents