Friday 21 December 2018

Google + Content reposting - May 18 2015


Digital and Interactive Games 2015 – Term 2, Week 4, Session 1
Today
ArrayList
Date and Time (new from Java 8)
Exception Handling

Chapter 9

try {
    Intention
}
catch {
    if exception is thrown
}
finally {
    After the catch of the first block if there is no error
}


ErrorHandlingSample
int numbers = new int(4);

try {
    // Force an error
    numbers[7] = 34;
}
catch (ArrayIndexOutOfBoundsException except) {
    System.out.println(“Index out of range”);
}



http://i483.photobucket.com/albums/rr193/Brenorenz/W11S001_zpsclfxqkyd.png


ExceptionCase.java
public class ExceptionCase {




Digital and Interactive Games 2015 – Term 2, Week 4, Session 2
Chapter 10

Today: I/0
Byte Stream
–    InputStream – Buffer InputStream
–    OutputStream

Character Stream


http://i483.photobucket.com/albums/rr193/Brenorenz/W11S0032_zpsdhs0vup9.png

in java.io

{
    h ()
}
catch (h) {
}
finally {
    .close
}


Classpath


fin = null;

try {
    open
}
catch (file not found) {
}

try {
    read
}
    catch (IOException)


A.txt
    Read

    Writing
B.txt


IOSample04

–    Test 04 and 05

1)    in bin folder
  
2)    in data folder


scores.dat
int:        player-id
double:    scores
double:    health
int:        check


     2 8 0 6 61 0 5 9    : 4
     |   |  |  |   |    |  |  |    :
1) 4     0    12 0  1.8  :
                  :
2) 4     0      3 0    9   :
         |              :
        36    15      :
        36 →: 4


Checksum

[80]
[16]
normal    : 888
vertex 1 888
           2 888
           3 888


http://i483.photobucket.com/albums/rr193/Brenorenz/W12005_zpsnei7lzx6.png

> 10 differences → files are
< 10 differences → print where the differences are


YouTube Tutorials : TheNewBoston (C++, web, etc)

Next Week
Wed: Java
Thurs: C++ Dungeon Game

IOSample06
// Read and Write Binary Data

int i = 34;
double d = 3.4505;
try (DataOutputStream fout = new DataOutputStream(new FileOutputStream(“myData”))) {
    fout.writeInt();
    fout.writeDouble();
}
catch(IOException except) {
    System.out.println(“Error when reading data”);
}

// Read the data back
try (DataInputStream fout = new DataInputStream(new FileInputStream(“myData”))) {
    i = fin.readInt();
    d = fin.readDouble();
    System.out.println(“i = ” + i);
    System.out.println(“d = ” + d);
}
catch (IOException except) {
    System.out.println(“Error when reading data”);
}

#cplusplus   #exceptionhandling   #gamedesign   #gameprogramming   #java   #tafe  





No comments:

Post a Comment