Download presentation
Presentation is loading. Please wait.
Published byLorin Heather Moore Modified over 8 years ago
1
Alice and Java Unit 7 1
2
Day 1 Objective: Gain an introduction to Java and Eclipse Essential skill: DM-1: Use technology to advance critical thinking and construct knowledge Website: For extra resources, check out the website http://www.cs.cmu.edu/~tcortina/activate/java/ http://www.cs.cmu.edu/~tcortina/activate/java/ 2
3
Lets get started! First, create a folder called “YourNameWorkspace” Copy Karl from my T-drive into your workspace Now open up Eclipse on your computer! You will be prompted to Select a Workspace—find the one you just created! 3
4
Lets Create our First Project File New Java Project Name this project “Karl” to match the name of the folder You will now have all of Karl’s Java Files loaded into your project The top will be all your Java Files The System Library is all the prebuilt java code that you can use The bottom will be all your text and image files 4
5
Karl When you run the program, you should see a maze with a robot Lets look at why this happens: To call the methods, we always will have it in the form: object.methodName(arguments); object refers to the class There are no arguments for these methods, but you still need parentheses 5
6
6 Karl the Robot - Methods Robot.move();before: front must be clear after: robot has advanced 1 space Robot.turnLeft();after: robot has rotated 90 degrees counter-clockwise Robot.makeDark();before: must be on light after: current square is now dark Robot.makeLight();before: must be on dark after: current square is not light Robot.load(“filename.txt”);loads a file with the robot on a grid Robot.onDark()returns True if the robot is currently on a dark square returns False if the robot is currently on a light square Robot.frontIsClear()returns True if the robot is facing an open space returns False if the robot is facing a wall
7
Classwork Explore the robot functions! Write the code to have the robot complete the maze Make sure to put this in the Karl Java File (the Karl tab at the top of eclipse) and under the completeMaze method 7
8
Day 2 Objective: Understand Robot Methods Essential skill: DM-1: Use technology to advance critical thinking and construct knowledge 8
9
Programming! Two Parts Logic: organization, problem solving, breaking big tasks into smaller parts Syntax: rules, words, curly braces, semi-colons, etc Need to practice and learn logic Can memorize syntax 9
10
Methods Lets open Eclipse and write a turnRight() method! Make sure we Java doc! /** Write your comments here. Make sure to explain what your method will do any what parameters are necessary. It will show up when you hover over the method and this is very useful for others to understand the methods you are writing */ After writing the turnRight() method, the code for completing the maze is a lot less work for us to write Make sure to write methods to keep your code neat and organized It’s more work for the compiler, but less work for us! 10
11
Other methods Lets write two more methods that we might like to have turnAround() backUp() Now lets try another challenge Load “stairs.txt” instead of “maze.txt” How can we write a method to clear the stairs 11
12
Classwork Write a method that will light all the blocks 12
13
Day 3 Objective: Understand If/Else statements Essential skill: DM-1: Use technology to advance critical thinking and construct knowledge 13
14
Review Syntax Rules Calling a method: fileName(class).methodName(); Creating a class: public className { method declarations } Method declarations: public static void methodName() { statements } 14
15
Problem solving Break complex problem into smaller pieces Name the pieces and think in terms of these names This is called Abstraction 15
16
Lets revisit cleanStairs What if the stairs were different? Open board1 in Eclipse and lets create another staircase Using an if/else statement, lets tests to see if the front is clear If/else structure: 16
17
Day 4-5: Project 7.1 17
18
Day 6 Objective: Boolean Expressions Essential skill: DM-1: Use technology to advance critical thinking and construct knowledge 18
19
19
20
Day 7 Objective: While statements Essential skill: DM-1: Use technology to advance critical thinking and construct knowledge 20
21
21
22
Day 8 Objective: Understand Variables Essential skill: DM-1: Use technology to advance critical thinking and construct knowledge 22
23
23
24
Days 9-13: Project 7.2 24
25
Day 14: Quiz 25
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.