[PDF] [PDF] Objects First With Java - Chapter 1

Why BlueJ? Page 6 Objects First with Java - A Practical Introduction using BlueJ, © David J Barnes, 



Previous PDF Next PDF





[PDF] Objects First with Java™ - BlueJ

10 mar 2016 · Sixth Edition Objects First with Java™ A Practical Introduction Using BlueJ Boston Columbus Indianapolis New York San Francisco Hoboken



[PDF] Objects first with java 6th edition - Weebly

Objects first with Java: A hands-on introduction provides the following for Objects First Java: Practical Practical Using BlueJ, the 6th edition of Source Code first with java 6th edition chapter 1 objects first with java 6th edition solutions pdf



[PDF] Objects First With Java 5th Edition Solutions

Using BlueJ Objects First with Java: A Practical Introduction Using Objects First With Java 5th Edition Solutions pdf - Free Sixth Edition, Pearson, 2016



[PDF] Objects First with Java A Practical Introduction using BlueJ Course

Third edition, Pearson Education, 2006 ISBN 0-13-197629-X Objects First with Java - A Practical Introduction using BlueJ, © David J Barnes, Michael Kölling 6



[PDF] Objects First With Java - Chapter 1

Why BlueJ? Page 6 Objects First with Java - A Practical Introduction using BlueJ, © David J Barnes, 



[PDF] Objects First With Java Using Bluej Solutions

may 1st, 2016 - objects first with java a practical introduction using bluej 6th edition First With Bluej Pdf''Objects First With Java 5th Edition PDF Free Download

[PDF] obligatoire en anglais synonyme

[PDF] obligatoire en anglais traduction

[PDF] obligatoire en anglais traduire

[PDF] occupational therapy short term goals examples

[PDF] ocr computer science end of unit quiz 2.1

[PDF] ocr computer science end of unit quiz 2.1 answers

[PDF] octave fft example

[PDF] oecd

[PDF] oecd alcohol consumption by country 2019

[PDF] oecd education 2030 pdf

[PDF] oecd teaching

[PDF] office administration pdf

[PDF] office management textbook pdf

[PDF] office of energy efficiency and renewable energy

[PDF] offre emploi culturel hauts de france

Understanding class

definitions

Looking inside classes

3. 0

Time for study

A full-time student week is 40 hours!

Examination

Course work: 3 assignments

Programming test

in lab; at computer practical task exam conditions

Programming test MUST

be passed (pass/fail mark; hurdle requirement)

Final mark calculated from coursework marks

Why BlueJ

Why Java?

Why BlueJ?

And, by the way:

Greenfoot

Main concepts to be covered

fields constructors methods parameters assignment statements

Ticket machines

Demo

Ticket machines -

a n internal view Interacting with an object gives us clues about its behaviour. Looking inside allows us to determine how that behaviour is provided or implemented. All Java classes have a similar-looking internal view.

Basic class structure

public class TicketMachine{

Inner part of the

class omitted.

The outer wrapper

of TicketMachine public class

ClassName

FieldsConstructorsMethods

The contents

of a class

Fields

Fields store values for an object.

They are also known as instance variables.

Use the

Inspect

option to view an object's fields.

Fields define the state of an object.

public class TicketMachine{ private int price;private int balance;private int total;Further details omitted. private int price; visibility modifier type variable name

Constructors

Constructors initialise an object.

They have the same name as their class.

They store initial values into the fields.

They often receive external parameter values for this. public TicketMachine(int ticketCost){ price = ticketCost;balance = 0;total = 0;

Passing data via parameters

Assignment

Values are stored into fields (and other variables) via assignment statements: variable = expression; price = ticketCost; A variable stores a single value, so any previous value is lost.

Accessor methods

Methods implement the behaviour of objects.

Accessors provide information about an object.

Methods have a structure consisting of a header and a body.

The header defines the method's

signature public int getPrice()

The body encloses the method's statements.

Accessor methods

public int getPrice(){ return price; return type method name parameter list (empty) start and end of method body (block) return statement visibility modifier Test public class CokeMachine{ private price;public CokeMachine(){ price = 300 }public int getPrice{ return Price;

What is wrong here?

(there are fiveerrors!) Test public class CokeMachine{ private price;public CokeMachine(){ price = 300 }public int getPrice{ return Price; int p

What is wrong here?

(there are fiveerrors!)

Mutator methods

Have a similar method structure: header and body.

Used to

mutate mutate (i.e. change) an object's state. Achieved through changing the value of one or more fields.

Typically contain assignment statements.

Typically receive parameters.

Mutator methods

public void insertMoney(int amount){ balance = balance + amount; return type method name parameter visibility modifier assignment statement field being mutated

Printing from methods

public void printTicket(){ // Simulate the printing of a ticket.System.out.println("###

System.out.println("# T

he BlueJ Line"); System.out.println("# Ticket");System.out.println("# " + price + " cents.");System.out.println("###

System.out.println();// Update the total col

lected with the balance. total = total + balance;// Clear the balance.balance = 0;

Reflecting on the ticket

machines

Their behaviour is inadequate in several ways:

No checks on the amounts entered.

No refunds.

No checks for a sensible initialisation.

How can we do better?

We need more sophisticated behaviour.

quotesdbs_dbs14.pdfusesText_20