Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 2 Recap CSE 115 – Spring 2007. Object Oriented Program System of objects that communicate with one another to solve some problem.

Similar presentations


Presentation on theme: "Week 2 Recap CSE 115 – Spring 2007. Object Oriented Program System of objects that communicate with one another to solve some problem."— Presentation transcript:

1 Week 2 Recap CSE 115 – Spring 2007

2 Object Oriented Program System of objects that communicate with one another to solve some problem.

3 Objects Objects are made up of: Properties Features that describe an object Capabilities Actions that an object can perform

4 Formalizing our Design UML class diagrams What is a class? Classes are the formal specification of what we want our objects to be and what we want them to be able to do.

5 Class Boxes in UML

6 Working with Eclipse Eclipse is an IDE that will help make writing our programs easier First we must Edit (write the program) Then Compile (Eclipse helps us with this by doing it as we type) Then Run (We select Run from a menu to run our programs)

7 Java Files Java source code files end with a.java extension Once the code has been compiled, files with a.class extension are created It is these.class files that are “run” by the Java Virtual Machine.

8 Java Syntax We need to learn about the syntax (grammar) rules of Java so that our programs will compile. Once our program compiles, we can run it. Question: Just because a program compiles, does that mean it will execute correctly?

9 Java Syntax (cont) Java is case sensitive (as is Unix)

10 Java Source Code File Made up of: Package declaration Class definition

11 Package Declaration package identifier ; package is a keyword in Java – a word that has a special meaning identifier represents a name. Here we are identifying a package by name.

12 Packages Way to organize our classes so that like classes are grouped together. Putting a class in a package forces you to put those classes in the same directory on the system.

13 Identifiers Programmers can pick out identifiers if we follow these rules. Identifiers must begin with a letter or underscore Followed by zero or more letters, digits, or underscores No special characters allowed in an identifier Keywords are not allowed to be identifiers

14 Identifiers (Style) Rules are enforced by compiler. Style enforced by community (i.e. your grade) Style for identifiers for packages is that the first letter of a package name is lower-case, all other letters are lower-case, and we do not see underscores in package names.

15 Nested Packages You can put a package inside of another package. This is indicated by using the dot (period) in between package names. On the system, nested packages are directories inside other directories. If you are using something outside of your current package, you must give the fully-qualified package name.

16 Class Definition Made up of: Class Header Class Body Class Body is made up of: Definitions of properties Definitions of capabilities

17 Class Header public class identifier public is a keyword that is an access control modifier. It tells who has access to something. If public, everyone has access. class is another keyword that indicates we are about to start the definition of a class. The identifier here represents the name of the class.

18 Names of Classes Must follow rules of identifiers. Style: First letter upper-case, rest lower-case. If more than one word, capitalize each new word. No underscores in class names. Whatever you name the class is whatever you will name the file the class is defined in.

19 Class Body Starts with a { Ends with a }


Download ppt "Week 2 Recap CSE 115 – Spring 2007. Object Oriented Program System of objects that communicate with one another to solve some problem."

Similar presentations


Ads by Google