Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. package ch.epfl.gameboj.component.memory;
  2.  
  3. import java.util.Arrays;
  4.  
  5. public final class Rom {
  6.  
  7. private final byte[] copy;
  8.  
  9. public Rom(byte[] data) throws NullPointerException {
  10. if ((data.length == 0)||(data.equals(null))) {
  11. throw new NullPointerException();
  12. }
  13. copy = Arrays.copyOf(data, data.length);
  14. }
  15.  
  16. public final int size() {
  17. return copy.length;
  18. }
  19.  
  20. public final int read(int index) throws IndexOutOfBoundsException {
  21.  
  22. return Byte.toUnsignedInt(copy[java.util.Objects.checkIndex(index,copy.length)]);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement