66 lines
1.2 KiB
Plaintext
66 lines
1.2 KiB
Plaintext
private void readFilmData(String fileName) throws IOException //1
|
||
{
|
||
File filmFile = new File(filename); //2
|
||
Scanner scanner1 = new Scanner( filmFile ); //3
|
||
while (scanner1.hasNext() ) //4 could throw a FileNotFoundExcpetion
|
||
{
|
||
String line = scanner1.nextLine(); //5
|
||
Scanner scanner2 = new Scanner(line);
|
||
scanner2.useDelimiter("[ ]*(,)[ ]*");
|
||
String filmTitle = scanner2.next();
|
||
String filmRating = scanner2.next();
|
||
int short = scanner2.nextInt();
|
||
// other code here to read & store rest of data
|
||
scanner2.close();
|
||
}
|
||
scanner1.close();
|
||
}
|
||
|
||
Citizen ->
|
||
English ->
|
||
Mancunian,
|
||
Londoner
|
||
Scots
|
||
|
||
Citizen person1;
|
||
English person2;
|
||
Scots person3;
|
||
Mancunian person4;
|
||
Londoner person5;
|
||
|
||
person1 = new Londoner();
|
||
person1 type Citizen. Legal
|
||
|
||
person2 = new Mancunian();
|
||
person2 type English. Legal
|
||
|
||
person5 = new English();
|
||
person5 type Londoner. Illegal
|
||
|
||
persona2 = new Scots();
|
||
person2 type English. Illegal
|
||
|
||
factorial(3) ->
|
||
x = 2
|
||
y = factorial(2)
|
||
factorial(2) ->
|
||
x = 1
|
||
y = factorial(1) -> 1
|
||
n*y = 2*1 = 2
|
||
n*y = 2*3 = 6
|
||
|
||
|
||
|
||
public int countTree(BinTreeNode t)
|
||
{
|
||
int count;
|
||
if (t == null)
|
||
count = 0;
|
||
else
|
||
count = countTree(t.leftChild) + 1 + countTree(t.rightChild);
|
||
return count;
|
||
}
|
||
|
||
|
||
|