Starting Software Development A Beginning. You Learn Software Development By Doing Software development.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

1 Lecture 16/3/11: Contents Example of an array of user-defined objects: Car and Carr Constructor Providing functionalities for a user- defined object.
1 CSCE 1030 Computer Science 1 Introduction to Object Oriented Programming.
Phil Campbell London South Bank University Java 1 First Steps.
The Point Class public class Point { public double x; public double y; public Point(double x0, double y0) { x = x0; y = y0; } public double distance(Point.
The Line Class Suppose you are involved in the development of a large mathematical application, and this application needs an object to represent a Line.
Exceptions Session 21. Memory Upload Creating Exceptions Using exceptions to control object creation and validation.
Topic 10 Java Memory Management. 1-2 Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each class.
J-Unit Framework.
April 20023CSG11 Electronic Commerce Java (1) John Wordsworth Department of Computer Science The University of Reading Room 129,
 In inheritance the child (subclass) chooses its parent (superclass)  Remember - only public or “protected” methods and variables are inherited  Should.
1 Classes Overview l Classes as Types l Declaring Instance Variables l Implementing Methods l Constructors l Accessor and Mutator Methods.
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
1 Introduction to Inheritance Overview l Inheritance ensures Reusability l Example of Inheritance l What is actually Inherited? l Overloading Vs. Overriding.
UML Basics & Access Modifier
Writing Classes (Chapter 4)
Programming With Java ICS201 University Of Ha’il1 Chapter 8 Polymorphism and Abstract Classes.
Object Oriented Programming … and other things you need to program in java.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
Interfaces. –An interface describes a set of methods: no constructors no instance variables –The interface must be implemented by some class. 646 java.
Checking Equality of Reference Variables. Arrays and objects are both “reference” types n They are allocated a chunk of memory in the address space n.
Refactoring An Automated Tool for the Tiger Language Leslie A Hensley
Methods in Java. Program Modules in Java  Java programs are written by combining new methods and classes with predefined methods in the Java Application.
Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 02 – Classes, Objects, Instances Richard Salomon and Umesh Patel Centre.
Object Oriented Programming (OOP) is a style of programming that incorporates these 3 features: Encapsulation Polymorphism Class Interaction.
Mixing integer and floating point numbers in an arithmetic operation.
Object-Oriented Programming Simple Stack Implementation.
Designing a Card Game Solitaire--Thirteens. Game.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Objects & Classes Weiss ch. 3. So far: –Point (see java.awt.Point) –String –Arrays of various kinds –IPAddress (see java.net.InetAddress) The Java API.
Outline Creating Subclasses Overriding Methods Class Hierarchies Visibility Designing for Inheritance Inheritance and GUIs The Timer Class Copyright ©
COP 2800 Lake Sumter State College Mark Wilson, Instructor.
PHY281 Scientific Java Programming ObjectsSlide 1 Classes & Objects In this section we will learn about Classes and Objects in Java :  What are Objects?
Chapter 3 Introduction to Classes and Objects Definitions Examples.
JAVA PROGRAMMING PART III. METHOD STATEMENT Form of method statement [ ] [static] ( [ ]) { } Example public static void main(String args[])
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Programming Languages and Paradigms Activation Records in Java.
Bank Account Example public class BankAccount { private double balance; public static int totalAccounts = 0; public BankAccount() { balance = 0; totalAccounts++;
Topic 8Classes, Objects and Methods 1 Topic 8 l Class and Method Definitions l Information Hiding and Encapsulation l Objects and Reference Classes, Objects,
Unified Modeling Language (UML)
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
© A+ Computer Science - Elevens is a lab about classes and Lists. List is a major concept being tested by the Elevens lab. Elevens.
Electronic Commerce Java (1)
Modern Programming Tools And Techniques-I
Java Memory Management
Introduction to Programming G50PRO University of Nottingham Unit 9 : Classes and objects Paul Tennent
Java Memory Management
University of Central Florida COP 3330 Object Oriented Programming
Adding Like Fractions Adding Like Fractions
University of Central Florida COP 3330 Object Oriented Programming
Chapter 5 Hierarchies IS-A associations superclasses subclasses
CompSci 230 Software Construction
Dr Shahriar Bijani Winter 2017
Writing Methods.
You can work in groups on this program.
Class Structure 28-Nov-18.
د.سناء الصايغ الفصل الأول البرمجة الشيئية
Object-Oriented Programming
More on Classes and Objects
Implementing Classes Chapter 3.
Example with Static Variable
CS2011 Introduction to Programming I Objects and Classes
Section 9.1 Introduction.
An Example of Inheritance
Introduction to Object-Oriented Programming
Java 1/31/2017 Back to Objects.
CS 200 More Classes Jim Williams, PhD.
Dr. R Z Khan Handout-3 Classes
CS 200 Creating Classes Jim Williams, PhD.
Presentation transcript:

Starting Software Development A Beginning

You Learn Software Development By Doing Software development

Starting Software Development What you will learn How to develop simple Object Oriented programs. How to create Objects to perform simple tasks. How to compile and run programs that use Objects. A simple understanding of the Java programming language. How to read a class diagram. A basic vocabulary of Software Development

Software Development Is Building Models

A Model is not The real thing Lorry Registration: F Make : Ford Axle Weight : 25 tonnes Driver : Fred public class Lorry{ String registration; String make; double axleWeight; String driver; } Lorry theLorry = new Lorry("F ","Ford",25.0,"Fred");

These are called attributes State Behaviour An object has state and behaviour Registration Make Axle Weight Driver Destination Load Depart Unload Load fuel Is In Transit Is Heading For... These are called methods These are called Values F Ford 25 tonnes Fred Birmingham

Lorry Registration: F Make : Ford Axle Weight : 25 tonnes Driver : Fred Status : LOADING Destination : BIRMINHAM DEPOT Left at : 8.35 Due at : Software Models the Real world

3 objects Suit Face Value

behaviour Draw Turn Stack SuitIs ColourIs IsPictureCard

An object is an instance of a class that has state and behaviour

public class SimpleCounter extends Object{ private int count; } // End class simplecounter count count = 5; 5 6 count++; count = count + 2; 8

public class SimpleCounter extends Object{ private int count; // the constructor public SimpleCounter (int startValue){ count = startValue; } // End SimpleCounter() // a simple action public void click (){ count++; } // End click() // a 'getter' public int getValue(){ return count; } // End getValue() } // End class simplecounter

Modifying a class Adding a new method

public class SimpleCounter extends Object{ private int count; // the constructor public SimpleCounter (int startValue){ count = startValue; } // End SimpleCounter() // a simple action public void click (){ count++; } // End click() // a 'getter' public int getValue(){ return count; } // End getValue() } // End class simplecounter // a new action public void add2(){ count++; } // End click()

SimpleCounter myCount = new SimpleCounter(21); 21 myCount count 22 myCount count myCount.click() anotherCount count 5 SimpleCounter anotherCount = new SimpleCounter(5)

public void click(){ count++; } 21 count public class SimpleCounterDemonstration extends Object{ public static void main (String[] args){ SimpleCounter myCount = new SimpleCounter(21); System.out.print( "First value : "); System.out.println( myCount.getValue()); myCount.click(); System.out.print( "Second value : "); System.out.println( myCount.getValue()); myCount.click(); System.out.print( "Third value : "); System.out.println( myCount.getValue()); } // End of main } // end of class SimpleCounterDemonstration myCount First Value : Second Value : Third Value :24 public int getValue(){ return count; }

21 count public class SimpleCounterDemonstration extends Object{ public static void main (String[] args){ SimpleCounter myCount = new SimpleCounter(21); SimpleCounter count2 = new SimpleCounter(5); System.out.println( "First value : " + myCount.getValue()); System.out.println( "Second value : " + count2.getValue()); myCount.click(); count2.click(); System.out.println( "Third value : " + myCount.getValue()); System.out.println( "Fourth value : " + count2.getValue()); myCount.click(); System.out.println( "Fifth value : " + myCount.getValue()); System.out.println( "Sixth value : " + count2.getValue()); } // End of main } // end of class SimpleCounterDemonstration myCount First value : 21 Second value :5 Third value :22 Fourth value :6 Fifth value :24 Sixth value : 6 count 5 count2 6

An object is an instance of a class that has state and behaviour

public class SimpleCounter extends Object{ private int count; // the constructor public SimpleCounter (int startValue){ count = startValue; } // End SimpleCounter() // a simple action public void click (){ count++; } // End click() // a 'getter' public int getValue(){ return count; } // End getValue() } // End class simplecounter A Reminder

public class SillyCounter extends SimpleCounter{ public SillyCounter (int theCount){ super(theCount); } public void click3(){ super.click(); } // End click3() } // End SillyCounter SillyCounter silly = new SillyCounter(3); SimpleCounter myCount = new SimpleCounter(4); silly.click();  myCount.click();  silly.click3();  myCount.click3();  Modifying a class Extending