1 / 6

Welcome to CSE 131

Welcome to CSE 131. Professor: Ron Cytron TAs: Ignacio DeErausquin , Kyle Cooper, Andy Gorman URL http://www.cs.wustl.edu/~cytron/cse131 Or: simply Google cytron cse131 Today: View from the top (anatomy of a Java program)

nyssa-casey
Download Presentation

Welcome to CSE 131

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Welcome to CSE 131 • Professor: Ron Cytron • TAs: Ignacio DeErausquin, Kyle Cooper, Andy Gorman • URL http://www.cs.wustl.edu/~cytron/cse131 • Or: simply Google cytron cse131 • Today: • View from the top (anatomy of a Java program) • Lab 0 (find the link on the course calendar / syllabus page • Friday: • Assigned reading shown on web page before each lecture • Participation grade requires responses about the reading

  2. Anatomy of a Java program • A Java program can have many packages. • Each package contains a set of related classes. • For example, a baseball package might have a Pitcher, Batter, and Scorekeeper class • The name of this package is lab0

  3. Anatomy of a Java program • A class describes the behaviors of an object. • This class is called RobotInstructions • It has just one kind of behavior which is to act • Other objects have more behaviors • For example, a Pitcher might throw a ball, catch a ball, etc.

  4. Anatomy of a Java program • The behaviors in a class are divided into methods • This method is named “act” • A Pitcher might have a method to throw a ball, catch a ball, etc.

  5. Anatomy of a Java program • For a method to do its job, it sometimes needs information • You see here an “incoming parameter” – a “robot” that is provided to the “act” method. • The act method can then issue instructions to the robot

  6. Anatomy of a Java program • This line of code sends a message to an object to tell it to do something • The object here is “robot” – it is the thing we are telling to do something • The method call is “forward” – we are asking the robot to go forward • This method call requires some information – how far forward should it go? • The value of 100 is the outgoing parameter, sent to the forward method, addressed to the robot.

More Related