Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Methods and Problem Decomposition9-10-2010Opening Discussion●Finishing “walking”.●Minute Essay responses–Do you know enough to do the IcP? What if you read ahead?–Do all classes have the same number of methods?–How do you keep track of this stuff? It seems arbitrary and overwhelming.–Can you make actors do two methods at once?More comments–Can you make your actor move in a way that isn't in the API?–What does Boolean mean?–What does PSPG stand for?–Can you give a different set of directions to each instance of an actor class?–How long should it take to solve a coding problem?–Is it possible to load your own images into Greenfoot?Even More Comments–Can the Greenfoot API change?–How many actors can you have in a scenario.–Could we add trees or cars?–Will we learn the other 6 statement types?–Could we use move(); in the person to make them walk like the Wombat?–Is there always more than one way to write code to do something?–The IcP is modifying an existing scenario.Writing New Methods●Last time we filled in some code in a method that was already part of the CityScape scenario.●Today we want to write some of our own methods. What type of functionality should we add to our person or our buildings?Problem Decomposition●One of the main reasons for having methods is that they allow us to break a big problem up into little pieces.●Computer Science is often about controlling complexity. Big problems are complex and therefore hard to solve.●You should always take a big problem and break it into pieces such that each piece is easy. Never solve a hard problem.Design Approaches●Top-down vs. bottom-up●Top-down–Start with the big problem and repeatedly break it into pieces.●Bottom-up–Start with little pieces you know how to do and put them together to solve bigger problems.Modulo and Integer Division●When you divide ints you get an int. Any fractional part is thrown away.●The remainder from division is given by the modulo operator, %.●We can do some fun things using these operators.●Let's make our person walk back and forth.Minute Essay●What do you think we should do with CityScape over the next few class meetings?●Remember that you will be showing off your interclass problems on Monday. If you have to miss class you should e-mail it to
View Full Document