130 likes | 374 Views
Introduction to BlueJ. BlueJ WHY…what’s the motivation?. an environment that is object-oriented. an environment that emphasizes classes and objects as its basic units of interaction , so that students are naturally led into a way of thinking in terms of classes and objects.
E N D
Introduction to BlueJ AP Computer Science 2012
BlueJWHY…what’s the motivation? • an environment that is object-oriented. • an environment that emphasizes classes and objects as its basic units of interaction, so that students are naturally led into a way of thinking in terms of classes and objects. • an environment that is sophisticated, but at the same time easy to use NO PSVM !!!!! AP Computer Science 2012
Coding: • Constructor • Objects and classes • State and behavior • Method signature and definition • Parameters • loops • int, String, boolean, void • TESTING AP Computer Science 2012
BlueJ Environment • Test Class • Class • Object AP Computer Science 2012
Behavior • State AP Computer Science 2012
Test Class-JUnit • Automate individual testing of separate methods • Create test method for each method in class… • numDigits tested by testNumDigits • The test class method should run through all test cases. AP Computer Science 2012
Testing for numDigits: @Test public void testNumDigits(){ assertEquals(1,one.numDigits()); assertEquals(2,two.numDigits()); assertEquals(3,three.numDigits()); assertEquals(4,four.numDigits()); assertEquals(5,five.numDigits()); } AP Computer Science 2012
Testing for sumDigits: @Test public void testSumDigits(){ assertEquals(1,one.sumDigits()); assertEquals(3,two.sumDigits()); assertEquals(6,three.sumDigits()); assertEquals(10,four.sumDigits()); assertEquals(15,five.sumDigits()); } AP Computer Science 2012
Test results AP Computer Science 2012
Fun with FunNumber • Using Test Classes • And • Pair programming: • 15 minute segments: • Station 1 navigator becomes Station 1 Coder; Station 1 coder moves. AP Computer Science 2012