9/12/2015IT 2751 IDE ( Integrated Development Environment ) 1.A customized plain text editor 2.Compiler 3.Loader 4.Debugging tool JDK (Java Development.

Slides:



Advertisements
Similar presentations
CS18000: Problem Solving and Object-Oriented Programming.
Advertisements

INHERITANCE BASICS Reusability is achieved by INHERITANCE
1 Inheritance: From membership point of view Vehicle SUV Honda Pilot Object Number Integer Double Base concept Derived concept Java Base class Derived.
Dialogs. Displaying Text in a Dialog Box Windows and dialog boxes –Up to this our output has been to the screen –Many Java applications use these to display.
Introduction To Computers and Programming Lecture 2: Your first program Professor: Evan Korth New York University.
Using JOptionPanes for graphical communication with our programs. Pages Horstmann 139.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Relational Operators Control structures Decisions using “if” statements  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 24 - Introduction to Java Applications and Applets Outline 24.1Introduction 24.2Basics of a Typical.
Developing User Interfaces (DUI) Chris North cs3724: HCI.
JOptionPane class. Dialog Boxes A dialog box is a small graphical window that displays a message to the user or requests input. A variety of dialog boxes.
OOP Languages: Java vs C++
Lab 1 City, Robot, Thing, Wall. Documentation of Classes and Methods.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Abstraction, Inheritance, and Polymorphism in Java.
1 Purposes: Learn JAVA 1.What is programming languages 2.How to solve problems by computers 1.a CS major student, get a degree in BS 2.a programmer  system.
Programming Languages and Paradigms Object-Oriented Programming.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
Algorithm development. The invention of the computer  Programming language developments: 1. Machine code 2. Assembler  easier to write, debug, and update.
CSCI 115 Computer Programming Overview. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
1 Part I : Chapter 01 Introduction to Java Programming.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Introduction to Java Programming with Forte Y. Daniel Liang.
Clement Allen, PhD Florida A&M University SUMMER 2006.
An Introduction to Software Development Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Programming Fundamentals 2: Simple/ F II Objectives – –give some simple examples of Java applications and one applet 2. Simple Java.
1 COMP 241: Object-Oriented Programming with Java Fall 2004 Lecture 1 September 27, 2004 Serdar Taşıran.
Lecture.1: Getting Started With Java Jiang (Jen) ZHENG May 9 th, 2005.
BCS 2143 Object Oriented Design Using UML. Objectives Objects Interactions Finding Classes Relationship Between Classes Attribute and Operation Class.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Pengantar OOP Class-Java. 2 Software Development Tools Using Sun Java SDK alone Source File(s) (.java) Programmer Compiler (javac) Class File(s) (.class)
1/16/2008ITK 1681 HardwareSoftware Theory 1800 AD  Architecture 1945 AD  What is Computer Science? Languages 1960 AD 
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Creating a Java Application and Applet
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
 2005 Pearson Education, Inc. All rights reserved. 1 Introduction to Classes and Objects.
For Friday Finish reading chapter 2 Complete WebCT quiz.
CSCI 115 Computer Programming Overview. Computer Software System Software –Operating systems –Utility programs –Language compilers Application Software.
1 Classes: A class is a concept of something Vehicle 4 wheels, seats, engine, windows, color…… accelerate, start, stop, turn, … attributes.
Object Oriented Programming Object and Classes Lecture 3 MBY.
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
3/21/2016IT 2751 Tow kinds of Lists Array What can be done? What can be easily done? student 1 student 2 student 3 student 4 Linked List student 2 student.
Introduction to Java Programming, 4E Y. Daniel Liang.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
1/28/2008ITK 1681 An enhanced robot Robot int street int avenue Direction direction ThingBag backback Robot(City aCity, int aStreet, int anAvenue, Direction.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
A Java Program: // Fig. 2.1: Welcome1.java // Text-printing program.
Robot Class name Attributes Constructor Services, methods
OBJECT ORIENTED PROGRAMMING II LECTURE 7 GEORGE KOUTSOGIANNAKIS
Internet and Java Foundations, Programming and Practice
OBJECT ORIENTED PROGRAMMING II LECTURE 8 GEORGE KOUTSOGIANNAKIS
Chapter 24 - Introduction to Java Applications and Applets
import becker.robots.City;
ITK 168 Section 13 Dr. Doug Twitchell.
Branching Statement Condition Statement Condition list 1 list
IDE (Integrated Development Environment)
F II 2. Simple Java Programs Objectives
Presentation transcript:

9/12/2015IT 2751 IDE ( Integrated Development Environment ) 1.A customized plain text editor 2.Compiler 3.Loader 4.Debugging tool JDK (Java Development Kit) = IDE+JRE Eclipse = IDE 1.vi (or emacs) 2.javac hello.java 3.java hello

9/12/2015IT 2752 Problems  Solutions cycle Problems System analyst, Project leader Algorithms Senior Programmers Programs in JAVA (or any high level Programming Language) compiler Assembly Assembler Machine code linker Results Customers Programmers Syntax Semantics (human) IDE (computers) VM

9/12/2015IT 2753 Procedure- v. Object- oriented To solve a program is: To find a way to manipulate data -- We design procedures Procedure-Oriented Programming Statements + functions  programs To find objects to model the problem – We choose data (object) Object-Oriented Programming Classes + Objects  programs (interfaces, methods, attributes…)

9/12/2015IT 2754 Robot int street int avenue Direction direction ThingBag backbag... Robot(City aCity, int aStreet, int aAvenue, Direction aDir) void move() void turnLeft() void pickThing() void putThing()... Services, methods Attributes UML class diagram for Robot Class name Constructor

9/12/2015IT 2755 Modeling what? Modeling Robots in a City with Software Classes. Robot int street int avenue Direction direction ThingBag backbag... Robot(City aCity, int aStreet, int aAvenue, Direction aDir) void move() void turnLeft() void pickThing() void putThing()... City String name int stree_No int ave_No City( )....

6 import javax.swing.JOptionPane; public class time{ public static void main(String args[]){ int x,y,z; String X,Y; X = JOptionPane.showInputDialog("Input x"); Y = JOptionPane.showInputDialog("Input y"); x = Integer.parseInt(X); y = Integer.parseInt(Y); z = x*y; JOptionPane.showMessageDialog( null, x + " * " + y + " = " + z, "The product of " + x + " and " + y, JOptionPane.PLAIN_MESSAGE ); System.exit(0); } classes methods package arguments Variable declaration class defined in the package 9/12/2015 IT 275 Anatomy of a Java Program

9/12/2015IT 2757 Task: deliver X from (1,2) to (3,1) and step away X import becker.robot.*; public class DeliverX{ public static void main(String args[]){ // set up Initial situation City A = new City(); Thing X = new Thing(A,1,2); Robot karel = new Robot(A,0,0, Direction.East); // direct the robot karel.move(); karel.turnLeft(); karel.move(); karel.pickThing(); karek.move(); karel.move(); karel.turnLeft(); karel.move(); karel.putThing(); karel.move(); } named Karel

9/12/2015IT 2758 import becker.robot.*; public class DeliverX{ public static void main(String args[]){ // set up Initial situation City A = new City(); Thing X = new Thing(A,1,2); Robot karel = new Robot(A,0,0,Direction.East); // direct the robot karel.move(); karel.turnLeft(); karel.move(); karel.pickThing(); karek.move(); karel.move(); karel.turnLeft(); karel.move(); karel.putThing(); karel.move(); } Anatomy of a Java Program

9/12/2015IT 2759 Package: collection of classes // Java API: Java Application Programming Interface // (java., javax.) // GUI: Graphical User Interface // // using swing package, JOptionPane class // showMessageDialog method import javax.swing.JOptionPane; public class TestPane{ public static void main(String args[]){ JOptionPane.showMessageDialog( null, "Welcome\nTo\nswing\nPackage"); System.exit(0); }

9/12/2015IT A Java Program: // Text-printing program. public class Welcome1 { // main method begins execution of Java application public static void main( String args[] ) { System.out.println( "Welcome to Java Programming!" ); } // end method main } // end class Welcome1 /********************************************************* *(C) Copyright by * * * **********************************************************/

9/12/2015IT Reusing Codes 1.Composition 2.Inheritance A class has another class, “has a” relation A class inherits another class, “is a” relation A car has an engine An SUV is a car

9/12/2015IT Composition: has a A DeliverX has a main, The main has a City, Thing, and a Robot import becker.robot.*; public class DeliverX{ public static void main(String args[]){ // set up Initial situation City A = new City(); Thing X = new Thing(A,1,2); Robot karel = new Robot(A,0,0, Direction.East); }

9/12/2015IT Composition: has a A BankAccount has a Client, has a List of BankTransaction public class BankAccount { private Client client; private List transactions; // other fields... }

9/12/2015IT Classes: A class is a concept of something Vehicle 4 wheels, seats, engine, windows, color…… accelerate, start, stop, turn, lock, Truck ………… Sedan ………… SUV ………… Matrix ………… Focus …………

9/12/2015IT Inheritance: From membership point of view Vehicle SUV Honda Pilot Object Number Integer Double Base concept Derived concept Java Base class Derived class A SUV is a vehicle, but a vehicle may not be a SUV Any SUV is a Vehicle

9/12/2015IT Inheritance: From functionality point of view SUV Vehicle Derived class Base class All vehicle can do, SUV can too The SUV has every properties and function of the Vehicle

9/12/2015IT UML (Unified Modeling Language) Diagram Vehicle TruckSedanSUV MatrixFocus Honda Pilot Matrix XRS

9/12/2015IT A - my_a: int +get_a():int B - my_b: int +get_b():int B - my_b: int +get_a():int +get_b():int = my_a is invisible to B

9/12/2015IT Base class (superclass) & Derived class (extended subclass) // A is a base class public class A { private int my_a; Public A(int a) { my_a = a; } public int get_a() { return my_a; } // B is a derived class Public class B extends A { private int b; public B(int a, int b) { super(a); this.b = b; } public int get_b() { return b; } A a = new A(2); B b = new B(3,7); I = a.get_a(); J = b.get_a(); K = b.get_b(); B inherits A’s functions and variables.

9/12/2015IT An enhanced robot Robot int street int avenue Direction direction ThingBag backback Robot(City aCity, int aStreet, int anAvenue, Direction aDir) void move() void turnLeft() void pickThing() void putThing() ExperimentRobot ExperimentRobot(City aCity, int aStreet, int anAvenue, Direction aDir) void turnAround(); void turnRight(); void move3(); = ExperimentRobot int street int avenue Direction direction ThingBag backback ExperimentRobot(City aCity, int aStreet, int anAvenue, Direction aDir) void move() void turnLeft() void pickThing() void putThing() void turnAround(); void turnRight(); void move3();

9/12/2015IT Selection sort algorithm in Java public static class SelectionSort { public void sort(int a[]) { for (int i = 0; i<a.length-1; i++) { // select one for a[i] int j = min(a,i); exchange(a,i,j); } // select the minimum between a[s] to the end private int min(int a[], int s) {int m = s; for (int i=s; i<a.length;i++) if (a[i] < a[m]) m=i; return m; } private void exchange(int[] a, int i, int j) { int temp = a[i]; a[i] = a[j]; a[j] = temp; } } // end of SelectionSort