starting software development a beginning. you learn software development by doing software...

24
Starting Software Development A Beginning

Post on 21-Dec-2015

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

Starting Software Development

A Beginning

Page 2: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

You Learn Software Development

By Doing Software development

Page 3: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

Starting Software DevelopmentWhat 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

Page 4: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

Software Development

Is

Building Models

Page 5: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

A Model is not

The real thing

Lorry

Registration: F423 675

Make : Ford

Axle Weight : 25 tonnes

Driver : Fred

public class Lorry{ String registration; String make; double axleWeight; String driver;}

Lorry theLorry = new Lorry("F423 675","Ford",25.0,"Fred");

Page 6: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

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 methodsThese are called Values

F423 675

Ford

25 tonnes

Fred

Birmingham

Page 7: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

Lorry

Registration: F423 675

Make : Ford

Axle Weight : 25 tonnes

Driver : Fred

Status : LOADING

Destination : BIRMINHAM DEPOT

Left at : 8.35

Due at : 11.50

Software Models the Real world

Page 8: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

3 objects

SuitFace Value

Page 9: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

behaviour

DrawTurnStack

SuitIsColourIsIsPictureCard

Page 10: Starting Software Development A Beginning. You Learn Software Development By Doing Software development
Page 11: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

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

behaviour

Page 12: Starting Software Development A Beginning. You Learn Software Development By Doing Software development
Page 13: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

public class SimpleCounter extends Object{

private int count;

} // End class simplecounter

count

count = 5;

56

count++;count = count + 2;

8

Page 14: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

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

Page 15: Starting Software Development A Beginning. You Learn Software Development By Doing Software development
Page 16: Starting Software Development A Beginning. You Learn Software Development By Doing Software development
Page 17: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

Modifying a classAdding a new method

Page 18: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

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++; count++; } // End click()

Page 19: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

SimpleCounter myCount = new SimpleCounter(21);

21

myCount

count

22

myCount

count

myCount.click()

anotherCount

count

5

SimpleCounter anotherCount = new SimpleCounter(5)

Page 20: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

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(); myCount.click(); System.out.print( "Third value : "); System.out.println( myCount.getValue()); } // End of main} // end of class SimpleCounterDemonstration

myCount

First Value : 21

22

Second Value :

2324

22

Third Value : 24

public int getValue(){ return count;}

Page 21: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

21

count

222324

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(); 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 : 21Second value : 5Third value : 22Fourth value : 6Fifth value : 24Sixth value : 6 count

5

count2

6

Page 22: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

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

behaviour

Page 23: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

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

Page 24: Starting Software Development A Beginning. You Learn Software Development By Doing Software development

public class SillyCounter extends SimpleCounter{

public SillyCounter (int theCount){ super(theCount); } public void click3(){ super.click(); super.click(); 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 classExtending