64
ITP © Ron Poet Lecture 2 1 Mental Models

ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models A mental model is a way of making sense of something we experience

Embed Size (px)

Citation preview

Page 1: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

1

Mental Models

Page 2: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

2

Mental Models

A mental model is a way of making sense of something we experience.

It can be used to make predictions when we have to "guess" at what to do.

The mental model need not correspond with "reality", provided the predictions work.

Page 3: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

3

Mental Model of a University

Lecturers are dedicated to help the students do the best they canwhile maintaining standards.

PredictionsIf we get stuck we can always ask a lecturer for

help.If we start an assignment too late through

laziness then we will not get an extension.

Page 4: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

4

Mental Model on anObject Oriented Program

Page 5: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

5

Objects are "Workers"

A mental model of an object oriented style of program is:A program is like an officeThe objects in the program are like workers in

the office.

They are "electronic" workers who can be created and destroyed in the blink of an eye.They always do exactly what they are told.

Page 6: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

6

Specialised Workers

Objects are specialised.They know about just one aspect of the

program.

They can do a limited range of tasks.These tasks should be related to their

specialisation if the program is designed well.The tasks are called methods.

Page 7: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

7

Objects are Good at Delegating

An object may delegate parts of its task to other objects.

If we are a customer, giving the object a task, we don't care how he does it.

The object is like a receptionist for a sub-department in our big office.

We give them a job, and some time later they give us the results.

Page 8: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

8

Inside the Sub-Department

If we are nosy we can follow the receptionist into the department.We will see several other "workers" scurrying

around making sure our task was done.Some of the work will be delegated to other

sub-department, who can delegate the work as well …

In most cases we don't need to know this.

Page 9: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

9

Engineers

In some cases we are engineers responsible for designing these sub-departments and

making sure they work.

In this case we need to be nosy. But we don't need to be engineers for every part of

the program.This is how multi-person projects are built.We are customers for parts of the code, engineers for

others.

Page 10: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

10

Unique, Omnipresent Workers

Some workers are unique and always available.

We can give them work whenever we wantAnd from anywhere in our program.

We should not have too many such objects.They influence all parts of our code.It gets difficult to remember them all.

Page 11: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

11

And The Clones

Other workers can be cloned, so that we can have as many copies of them as we want.They each have different personal detailsBut they have the same methods.

We must create them when we need them. If we ignore them then Java will quietly remove

them when they are no longer needed.We don’t need to remember to remove them.

Page 12: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

12

Only One Objects Is At Work

In many programs,Only one object is working at any one time.The other object are either

Waiting for another object to return work.Waiting to be given some work.

The program is started of by a main object.

Page 13: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

13

Multiple Thread

Some programs can use threads.Each thread has just one object working.But the program has many objects working

simultaneously.One for each thread.

Threads are covered in Advanced Programming.

Page 14: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

14

The main Object

In Java every program must have at least one object.

This is the main object.It starts off the computation.It is a unique, omnipresent object.We must define what it does ourselves.

Page 15: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

15

Example Programs As Objects

Page 16: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

16

Program 1

public class Ex1 {

public static void main(String[] arg)

{

System.out.println("Hello World");

}

}

Page 17: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

17

main Object Ex1

All main classes are defined in the same way:public class < name >

{

public static void main(String[] arg)

{

< program goes here >

}

}

The various special words will be explained as the course progresses.

Page 18: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

18

System.out Object

This is unique, omnipresent object supplied by Java.

Its area of responsibility is outputing message to a text window.

It has many different methods, all associated with output.

println outputs text, followed by a newline.

Page 19: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

19

Method Call

We give an object some work by using a method.

The form isobject . method name ( info ) ;

In this example.Object is System.outMethod name is printlnInfo is “Hello World”

Page 20: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

20

Program 1 As People

We define what Mr. main has to do. He wants to say “Hello World” He knows that Ms System.out does this. He gives her the println task. He waits until she has finished The he finishes as well, his work is done. He could have used her angry twin sister Ms System.err, who says everything in red.

Page 21: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

21

The Console Family

Mr main also knows that the Console family will say what he wants in a prettier window.

There is no omnipresent Console object so he must create a member of the family first.

He must choose their name and thinks con sounds good. He could choose any name.

He creates the Console objectConsole con = new Console();

Page 22: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

22

The Console Family

Con also understands the println task.con.println("Hello World");

Hello World is printed in a different place. The instruction (println) and info (“Hello World”) are the

same But the workers (con and System.out) are different.

Page 23: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

23

The FileOut Family

Now Mr main decides that he wants his words to be stored permanently in a file.

The FileOut family will do this for him.fout is such a nice name! He must tell fout the name of the file.

FileOut fout = new FileOut("greeting"); The FileOut family also does println.

fout.println("Hi Ron");

Page 24: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

24

The FileIn Family

Members of FileIn read from a file.This is more complicated.We need to learn some new things before

returning to FileIn.

Page 25: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

25

Sequential Statements

Page 26: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

26

Sequential Processing

Each bit of processing consists of a sequence of statements.

The statements are executed one after the other.

One statement must finish before the next one starts.

Page 27: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

27

A Simple Statement

A statement is a single activity.There are many different types of

statements.They each end with a semi-colon.Our simple programs have had up to 6

statements.A statement can be spread over several lines

if that makes it easier to read.

Page 28: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

28

Compound Statement

A compound statement is a sequence of statements.They can be either simple or compound.

A compound statement starts with { and ends with }.

They group statements in more complex structures.

Every method contains its instructions in a compound statement.

Page 29: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

29

Example Program

Our first example program contained a compound statement, the method body.

Which contained one simple statement.public class Ex1 {public static void main(String[] arg){System.out.println("Hello World");

}}

Page 30: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

30

FileIn Program

The FileIn program is slightly more complex.

{

Console con = new Console();

FileIn fin = new FileIn();

String word = "";

word = fin.readWord();

con.println(word);

}

Page 31: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

31

Variables

Page 32: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

32

Mental Model of Computer Memory

Computer programs store temporary values in their memory.

We need to picture how this works.We can think of a piece of computer

memory as a sticky box.Initially this box is empty.But we can place a single value in it.

Page 33: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

33

Copying Values

The sticky part means that we cannot take the value out of the box again.

It can never become empty once we give it a value.

We can make as many copies of the value stored in the box as we want to.

Page 34: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

34

Changing Values

The only way we can change the value in the box is by putting a new value in it.

The old value is lost permanently.We can now take copies of this new value.A box can only store one value at a time.

Page 35: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

35

Variables

These computer memories or boxes are called variables.

We must give them names, called identifiers. Identifiers must start with a letter.

Followed by letters and/or numbers. By convention Java variable names start with a

lower case letter. If they are a sequence of words, then the start of

each word except the first is capitalised.

Page 36: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

36

Meaningful Identifiers

We can choose the names in our program so that it is easier for humans to read.Computers don't care what the names are.

Don't make them too long.circleAreaconfoutx2, y2, z2

Page 37: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

37

Types

Page 38: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

38

Different Types of Information

Our computer program can store different types of information in each of its boxes.WordsNumbersObjects

Words have type String Numbers can either be:

Whole numbers or integers, type intReal numbers (with a decimal point), type double.

Page 39: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

39

Different Types of Information

The boxes can also store objects, with different type, such as Console, FileOut etc.

We can create our own types of objects.See later in the course.

Page 40: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

40

Literals

A literal is an actual value written in the text of the program.

Different types have different forms of literals. A String literal must be inside "".

"Hello World" An int literal is a whole number, eg 42. A double literal has a decimal point and/or

exponential notation, eg 3.14159, 6.0221415e23.

Page 41: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

41

Variable Definitions

We have different boxes for different types.A String type box can only store text.We must tell the computer about every box

we are going to use before we use it.This is a variable definition.It must include both a type and a name.

Page 42: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

42

Variable Definitions (2)

Variable definitions are all statements.Terminated by ;

They can occur anywhere inside a compound statement.

ExamplesString firstName, lastName;int i, j, k;double x, y, z;

Page 43: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

43

Initialisation

We can choose to give each box an initial value when we define it.

Otherwise Java will start it off with a zero numerical value or empty text.

Other programming languages may create a variable containing junk.

Page 44: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

44

Initialisation (2)

It is safer to initialise variables when they are created.To prevent accidentally using a junk value.

Use = in the variable definition.Examples

Console con = new Console();

String word = "";int i=0, j=0, k=0;

Page 45: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

45

Operations

Each type has a set of operations that work with that type.

Numbers (int, double) have the usual arithmetic: +, -, *, /

Strings have join operations, called concatenation.

Page 46: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

46

Expressions

An expression is a calculation that involves some operations.

An arithmetic formula, for example.

Page 47: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

47

Values

Values are results of calculations.A copy of the values stored in a variable 'box'.The result of arithmetic.A literal.

Values can be given to methods as informationprintln("Hello World")

Or stored in memory (variables).

Page 48: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

48

Assignment

Assignment changes the value stored in a variable. The old value is no longer there.

The assignment operator is = This can be confusing.

It does not mean 'is equal to' but copy right to left.Get the right mental model!String greeting;

greeting = "Hi Ron";

Page 49: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

49

Examples

Let us define a variable.double radius = 3.0;

Calculate the area and store the value in a variable.double area = 3.14159 * radius * radius;

Copy the value stored in the radius box (twice), Multiply by a literal, using the * operator. Produce an arithmetic expression. Store the result in a variable (assignment).

Page 50: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

50

Strings

Page 51: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

51

String Type

A String is a sequence of characters.A character is a letter, a digit, punctuation,

spaces, newline, tabs and other special characters.

An empty String literal is "".A newline in a String is \n.

"line1\nline2"

Page 52: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

52

Concatenation

Concatenation means joining Strings.We use the + operator.It will join any two String values.

String firstName = "Ron", lastName = "Poet";

String fullName = firstName + " " + lastName;

Page 53: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

53

Conversions from Numbers

A number can be converted to a String using concatenation.Provided it is not the first item.

If the number is a double then it will be converted with a lot of decimal digits.Not under user control.But see later.

Page 54: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

54

Examples

If the value 3 is stored in x and 7 in y, then the string

"x = " + x + " y = " + y; Will become

x = 3 y = 7 There is a trick if we want to create a string where the first

part is a number. We make the first part the empty string “”

"" + 42 + " is a special number";

Page 55: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

55

The FormatIO Package

Page 56: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

56

Formatted Input and Output

The FormatIO package provides a number of classes (families in our mental model) to provide convenient input and output.

Java is not very good in this area.FormatIO was initially written for Java 1.0.Rewritten for Java 1.1Not yet rewritten for Java 5.0 (hence

warnings)

Page 57: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

57

Output Methods

All classes in FormatIO that support output support the same methods.They just output to different places.

Just consider two for now.print(String) // output the String valueprintln(String) // print followed by newline

print("Hi Ron");print(firstName + " " + lastName);

Page 58: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

58

Input Methods

All FormatIO classes that support input support the same methods.They just input from different places.

Just consider two for now.readWord() // reads up to next space or newline

readLine() // reads next line

Page 59: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

59

Input Methods

They both return a String value, which must be used somehow.Stored in a variable

String word = con.readWord();passed to another method

System.out.println(con.readWord());part of an expression.

String name = con.readWord() + " " + con.readWord();

Page 60: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

60

Console Class

This supports both input and output.It can be created with a default size and name,

or the name and size can be provided.The size is the number of rows of letters followed

by number of columns.con1 = new Console();

con2 = new Console("Rons console");

con3 = new Console(10, 40);

con4 = new Console("small", 5, 20);

Page 61: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

61

Console Class (2)

You can have as many console objects as you wish.It is normal to only have 1.

The save button saves the output.You are prompted for a file name.

The close button closes that window.The quit button closes the program.

Page 62: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

62

FileOut, FileIn

They write to a file or read from a file.You can provide a filename when you

create them.FileOut fout = new FileOut("greeting");

If you don't provide a file name then you will get a file chooser window.FileOut fout = new FileOut();

Page 63: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

63

StringIn

If we have a String variable that contains text we can treat it as a source of input.We can read the text one word at a time.

We create a StringIn variable and then use the method readWordOr any other FormatIO input method.

Page 64: ITP © Ron Poet Lecture 2 1 Mental Models. ITP © Ron Poet Lecture 2 2 Mental Models  A mental model is a way of making sense of something we experience

ITP © Ron PoetLecture 2

64

StringIn Example

String fullName = "Ron Poet";

StringIn sin = new StringIn(fullName);

String firstName = sin.readWord();

String lastName = sin.readWord();