package As7BattleShip;

Size: px
Start display at page:

Download "package As7BattleShip;"

Transcription

1 package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: Runs the battleship game Input: ship placement board files and computer player type Output: Creates a JFrame that displays the battleship board, where ships are placed and where they've been hit. import java.io.file; import java.io.filenotfoundexception; public class BattleshipDriver { Main args Command line arguments public static void main(string args[]) { try { BattleshipBoard b; File boardfile = new File(args[0]); File opponentboardfile = new File(args[1]); b = new BattleshipBoard(boardFile); b.opponentboard(opponentboardfile); b.cpuplayer(); b.setvisible(true); catch (FileNotFoundException BattleshipException e) { System.out.println(e.getMessage()); System.exit(-1); package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: Runs the battleship game Input: ship placement board files and computer player type Output: Creates a JFrame that displays the battleship board, where ships are placed and where they've been hit. Also announces winner. import java.awt.color; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.io.; import java.util.arraylist; import javax.swing.jframe; import javax.swing.joptionpane; import javax.swing.jpanel;

2 @SuppressWarnings("serial") public class BattleshipBoard extends JFrame { Static constant to indicate a board location is empty public static final char EMPTY = '.'; The 2D array representing the board private char board[][]; The 2D array representing the opponent's board private char oppboard[][]; The 2D array representing the CPU's FireButtons private FireButton fboppboard[][]; The 2D array representing the player's FireButtons private FireButton fbboard[][]; The number of battleships left private int numbattleshipsleft; The number of opponent's battleships left private int numoppbattleshipsleft; The ID of the current ship being placed private int currentshipid; The number of rows private int numrows; The number of columns private int numcols; Maintains information about the shots taken by each ship public ArrayList<Integer> shipinfo; Maintains information about the shots taken by each of the opponent's ship public ArrayList<Integer> opponentshipinfo; FireButtons for opponent private FireButton fb; FireButtons for player private FireButton fbp;

3 Creates the main panel that will hold the 2 boards JPanel mainpanel = new JPanel(new GridLayout(0, 2)); Creates the player's board panel private JPanel playerpanel; Creates the opponent's board panel private JPanel opponentpanel; Creates listener objects for the FireButtons private ButtonListener listener; CPU type public CPU cpu; Constructor for the Battleship Board. File must have 10 lines, with exactly 10 characters per line. '.' represents EMPTY. A unique number (0, 1, 2, 3, or 4) will represent each boardfile a text file with a 10x10 character grid, representing a battleship FileNotFoundException if the board file is not richmaja public BattleshipBoard(File boardfile) throws FileNotFoundException { this.numrows = 10; this.numcols = 10; this.board = new char[numcols][numrows]; this.fbboard = new FireButton[numCols][numRows]; this.listener = new ButtonListener(); this.shipinfo = new ArrayList<>(); this.numbattleshipsleft = 5; //Add 5 entries to shipinfo for (int i = 0; i < 5; i++) { shipinfo.add(0); //create the board frame setsize(700, 400); settitle("battleship Board"); setdefaultcloseoperation(exit_on_close); this.add(mainpanel); try { if (!boardfile.exists()) { throw new FileNotFoundException("Error Reading: " + boardfile.getname()); //Confirm file worked System.out.println("Reading " + boardfile.getname()); //create player board this.playerpanel = new JPanel(new GridLayout(numRows, numcols));

4 playerpanel.setborder(javax.swing.borderfactory.createtitledborder(null, "Player Board", javax.swing.border.titledborder.left, javax.swing.border.titledborder.top)); mainpanel.add(playerpanel); try (FileReader fr = new FileReader(boardFile); BufferedReader br = new BufferedReader(fr)) { String line; int linecounter = 0; while ((line = br.readline())!= null) { for (int i = 0; i < line.length(); i++) { char currentcharacter = line.charat(i); board[i][linecounter] = currentcharacter; linecounter++; //add the file contents to the board and create the fire buttons for (int c = 0; c < this.numcols; c++) { for (int r = 0; r < this.numrows; r++) { try { this.fbp = new FireButton(c, r); this.fbp.addactionlistener(this.listener); if (!String.valueOf(board[r][c]).equals(String.valueOf(BattleshipBoard.EMPTY))) { this.fbp.settext(string.valueof(board[r][c])); fbp.setbackground(color.yellow); else { fbp.settext(""); fbboard[r][c] = this.fbp; playerpanel.add(fbp); //disable player's board fbp.setenabled(false); //set the margins so the buttons are together fbp.setmargin(new java.awt.insets(0, 0, 0, 0)); //set the ship number into the ship array int shipidval = Integer.parseInt(board[c][r] + ""); shipinfo.set(shipidval, shipinfo.get(shipidval) + 1); catch (NumberFormatException e) { catch (IOException e) { System.out.println("Error: " + e.getmessage()); //print the board to confirm //print(); System.out.println(shipInfo); Builds the opponent's board. File must have 10 lines, with exactly 10 characters per line. '.' represents EMPTY. A unique number (0, 1, 2, 3, or 4) will represent each boardfile a text file with a 10x10 character grid, representing a

5 battleship FileNotFoundException if the board file is not found public void opponentboard(file boardfile) throws FileNotFoundException { this.numrows = 10; this.numcols = 10; this.oppboard = new char[numcols][numrows]; this.fboppboard = new FireButton[numCols][numRows]; this.listener = new ButtonListener(); this.opponentshipinfo = new ArrayList<>(); //this.shipinfo = new ArrayList<>(); this.numoppbattleshipsleft = 5; //Add 5 entries to shipinfo for (int i = 0; i < 5; i++) { opponentshipinfo.add(0); //shipinfo.add(0); try { if (!boardfile.exists()) { throw new FileNotFoundException("Error Reading: " + boardfile.getname()); System.out.println("Reading " + boardfile.getname()); //Create the opponent panel and add it to the main panel this.opponentpanel = new JPanel(new GridLayout(numRows, numcols)); mainpanel.add(opponentpanel); opponentpanel.setborder(javax.swing.borderfactory.createtitledborder(null, "Opponent Board", javax.swing.border.titledborder.left, javax.swing.border.titledborder.top)); //Read the file to create the board and where to place the ships try (FileReader fr = new FileReader(boardFile); BufferedReader br = new BufferedReader(fr)) { String line; int linecounter = 0; while ((line = br.readline())!= null) { for (int i = 0; i < line.length(); i++) { char currentcharacter = line.charat(i); oppboard[i][linecounter] = currentcharacter; linecounter++; //fill the board with the FireButtons for (int c = 0; c < this.numcols; c++) { for (int r = 0; r < this.numrows; r++) { try { this.fb = new FireButton(r, c); this.fb.addactionlistener(this.listener); //place the ships on the board or empty space where no ship is if (!String.valueOf(oppboard[r][c]).equals(String.valueOf(BattleshipBoard.EMPTY))) { this.fb.setname(string.valueof(oppboard[r][c])); else { fb.setname(""); this.fb.setenabled(true); this.fb.setmargin(new java.awt.insets(0, 0, 0, 0)); //add the FB to the FB board this.fboppboard[r][c] = this.fb; //add the panel to the board

6 1); opponentpanel.add(this.fb); int shipidval = Integer.parseInt(oppboard[c][r] + ""); opponentshipinfo.set(shipidval, opponentshipinfo.get(shipidval) + catch (NumberFormatException e) { catch (IOException e) { System.out.println("Error: " + e.getmessage()); //print(); System.out.println(opponentshipInfo); Constructs the CPU player cpuplayer Systematic player for "s" and Random player for BattleshipException is neither "s" or "r" //public CPU CPUplayer(String cpuplayer) throws BattleshipException { public CPU CPUplayer() throws BattleshipException { Object[] options = {"Systematic","Random"; int result = JOptionPane.showOptionDialog(null, "Select the type of CPU you would like to play against", "Battleship", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE,null,options,options[0]); if (result == 0) { System.out.println("Systematic opponent selected"); return cpu = new SystematicCPU(); else if (result == 1) { System.out.println("Random opponent selected"); return cpu = new RandomCPU(); else { throw new BattleshipException("Incorrect computer player argument"); if (cpuplayer.equalsignorecase("s")) { System.out.println("Systematic opponent"); return cpu = new SystematicCPU(); else if (cpuplayer.equalsignorecase("r")) { System.out.println("Random opponent"); return cpu = new RandomCPU(); else { throw new BattleshipException("Incorrect computer player argument"); //return cpu = new SystematicCPU(); Getter for the number of rows in the The number of rows in the Battleship board public int getnumrows() { return this.numrows; Getter for the number of columns in the The number of columns in the Battleship board public int getnumcols() { return this.numcols;

7 Gets the number of Battleships The number of battleships left public int getnumbattleshipsleft() { return this.numbattleshipsleft; Gets the number of opponent's Battleships The number of battleships left public int getoppnumbattleshipsleft() { return this.numoppbattleshipsleft; Checks if the cell is col The row The true if the cell is occupied public boolean isoccupied(int col, int row) { if (row >= 0 && row < getnumrows() && col >= 0 && col < getnumcols()) { return board[col][row]!= EMPTY; return false; Returns the char value at a certain row and column of the col The column on which the cell row The row on which the cell the char value at a certain row and column of the board public char getcellcontent(int col, int row) { if (row >= 0 && row < getnumrows() && col >= 0 && col < getnumcols()) { return this.board[col][row]; return EMPTY; public char getoppcellcontent(int col, int row) { if (row >= 0 && row < getnumrows() && col >= 0 && col < getnumcols()) { return this.oppboard[col][row]; return EMPTY; Fires a shot at an opponent's col The col coordinate of the row The row coordinate of the true if an enemy battleship is hit, false otherwise. If you fire twice at the same spot and a battleship was at that spot, this method returns true both IndexOutOfBoundsException if row or col are out of bounds public boolean fireshot(int col, int row) throws IndexOutOfBoundsException {

8 if (this.getoppcellcontent(col, row)!= BattleshipBoard.EMPTY) { int shipid = Character.digit(this.getOppCellContent(col, row), 10); Integer shotsleft = this.opponentshipinfo.get(shipid); shotsleft--; if (shotsleft == 0) { this.numoppbattleshipsleft--; this.opponentshipinfo.set(shipid, new Integer(shotsLeft)); System.out.println("Hit ship: " + shipid + " Shots left: " + shotsleft + " Ships left:" + this.numoppbattleshipsleft); // Decide winner and alert player if (isgameover()) { endgame(0); else { //Call opponent's shot cpushot(cpu.cpucol(), cpu.cpurow()); //System.out.println("Hit at " + col + ", " + row); return true; else { //MISS //System.out.println("Miss at " + col + ", " + row); //Call opponent's shot cpushot(cpu.cpucol(), cpu.cpurow()); return false; Fires a shot at a player's col The col coordinate of the row The row coordinate of the true if an enemy battleship is hit, false IndexOutOfBoundsException if row or col are out of bounds public boolean cpushot(int col, int row) throws IndexOutOfBoundsException { this.fbp = fbboard[col][row]; if (fbp.getbackground().equals(color.blue) fbp.getbackground().equals(color.red)) { System.out.println("Shooting again"); cpushot(cpu.cpucol(), cpu.cpurow()); return false; System.out.println("CPU shooting at " + col + ", " + row); if (this.getcellcontent(col, row)!= BattleshipBoard.EMPTY) { int shipid = Character.digit(this.getCellContent(col, row), 10); Integer shotsleft = this.shipinfo.get(shipid); shotsleft--; if (shotsleft == 0) { this.numbattleshipsleft--; this.shipinfo.set(shipid, new Integer(shotsLeft)); System.out.println("CPU Hit ship: " + shipid + " Shots left: " + shotsleft + " Ships left:" + this.numbattleshipsleft); if ((fbp.gettext().matches("[0-9]")) this.fbp.getbackground().equals(color.yellow)) { //System.out.println("Hit at " + col.getcolumn() + ", " + row.getrow());

9 fbp.settext("h"); //if hit twice, skip the fireshot method fbp.setbackground(color.red); //Decide winner and alert player if (isgameover()) endgame(1); return true; else { if (fbp.gettext().equals("")) { fbp.setbackground(color.blue); //System.out.println("Miss at " + col.getcolumn() + ", " + row.getrow()); fbp.settext("m"); System.out.println("CPU Miss at " + col + ", " + row); return false; ButtonListener class for FireButtons When button is pressed, check if it's been hit before and skip if it has. Otherwise if miss, change to M and make blue, if hit change to H and make red public class ButtonListener implements ActionListener //what cell did the button hit public void actionperformed(actionevent arg0) { fb = (FireButton) arg0.getsource(); Cell col = fb.getcell(); Cell row = fb.getcell(); //if missed or shot at twice, skip the fireshot method if (fb.getbackground().equals(color.blue) fb.getbackground().equals(color.red)) { return; //miss if (fb.getname().equals("")) { //System.out.println("Miss at " + col.getcolumn() + ", " + row.getrow()); fb.setbackground(color.blue); fb.settext("m"); fireshot(col.getcolumn(), row.getrow()); //hit if (fb.getname().matches("[0-9]")) { //System.out.println("Hit at " + col.getcolumn() + ", " + row.getrow()); //int shipid = Integer.parseInt(fb.getName()); fb.settext("h"); fb.setbackground(color.red); fireshot(col.getcolumn(), row.getrow()); Prints the board, for testing only public void print() {

10 for (int r = 0; r < this.numrows; r++) { StringBuilder sb = new StringBuilder(this.numCols); for (int c = 0; c < this.numcols; c++) { sb.append(this.board[c][r]); System.out.println(sb.toString()); Check if all the ships on either player or CPU board have been sunk Returns true if game is over, false true if game is over, false otherwise public boolean isgameover() { if ((this.numbattleshipsleft <= 0) (this.numoppbattleshipsleft <= 0)) { return true; else { return false; public void resetgame() { this.numbattleshipsleft = 5; this.numoppbattleshipsleft = 5; this.shipinfo.clear(); this.opponentshipinfo.clear(); for (int i = 0; i < 5; i++) { shipinfo.add(0); opponentshipinfo.add(0); //add the file contents to the board and create the fire buttons for (int c = 0; c < this.numcols; c++) { for (int r = 0; r < this.numrows; r++) { try { this.fbp = fbboard[r][c]; if (!String.valueOf(board[r][c]).equals(String.valueOf(BattleshipBoard.EMPTY))) { this.fbp.settext(string.valueof(board[r][c])); fbp.setbackground(color.yellow); else { fbp.settext(""); fbp.setbackground(null); fbboard[r][c] = this.fbp; //set the ship number into the ship array int shipidval = Integer.parseInt(board[c][r] + ""); shipinfo.set(shipidval, shipinfo.get(shipidval) + 1); catch (NumberFormatException e) { cpu.setcpucol(-1);

11 cpu.setcpurow(-1); //fill the board with the FireButtons for (int c = 0; c < this.numcols; c++) { for (int r = 0; r < this.numrows; r++) { try { this.fb = fboppboard[r][c]; this.fb.settext(""); this.fb.setbackground(null); //place the ships on the board or empty space where no ship is if (!String.valueOf(oppboard[r][c]).equals(String.valueOf(BattleshipBoard.EMPTY))) { this.fb.setname(string.valueof(oppboard[r][c])); else { fb.setname(""); this.fb.setenabled(true); //this.fb.setmargin(new java.awt.insets(0, 0, 0, 0)); int shipidval = Integer.parseInt(oppboard[c][r] + ""); opponentshipinfo.set(shipidval, opponentshipinfo.get(shipidval) + 1); catch (NumberFormatException e) { Handles end of game boolean - true for player win, false for CPU 0 if play again, 1 if no and exit public void endgame(int winner) { String winnermsg; if (winner == 0) winnermsg = "You win! "; else winnermsg = "You lose. "; //show dialog and ask to play again int result = JOptionPane.showConfirmDialog(null, winnermsg + "Do you want to play again?", "Game Over", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == 0) resetgame(); else System.exit(0); package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: Manages the 2 CPU players: RandomCPU and SystematicCPU public class CPU { int numrow = 10; // number of rows for the board int numcol = 10;// number of columns for the board

12 //set back starting pos 1 column/row from start to make the methods easier for SystematicCPU int currentcol = -1; int currentrow = -1; Default method to get column to shoot at public int CPUcol() { return currentcol; Default method to get row to shoot at public int CPUrow() { return currentrow; public void setcpucol(int col) { currentcol = col; public void setcpurow(int row) { currentrow = row; package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: Cell defines the cells for FireButton public class Cell { private int row; private int col; public Cell(int col, int row){ this.row = row; this.col = col; public int getrow(){ return this.row; public int getcolumn(){ return this.col; package As7BattleShip; Program: BattleshipBoard.java

13 Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: FireButtons are used to select target cells on boards import public class FireButton extends JButton { private Cell cell; public FireButton(int col, int row){ cell = new the cell the button is at public Cell getcell(){ return this.cell; package As7BattleShip; Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: RandomCPU inherits the CPU class. The random player randomly selects a position on the board and shoots at it. If the player has already shot that location, the player picks a different location and shoots at it. public class RandomCPU extends CPU { public RandomCPU() { super(); Select a random public int CPUcol() { currentcol = (int) (Math.random()(numCol)); return currentcol; Select a random public int CPUrow() { currentrow = (int) (Math.random()(numRow)); return currentrow; package As7BattleShip;

14 Program: BattleshipBoard.java Author: Kevin Nider Date: 11/18/12 Description: Assignment 7: SystematicCPU inherits the CPU class. The systematic player randomly starts at (0,0) and moves across the board and down once it reaches the end. public class SystematicCPU extends CPU { public SystematicCPU() { super(); Start at row one, when column starts over, start on the next public int CPUrow() { if (currentcol == 0) { currentrow++; else { return currentrow; return currentrow; Start at column 0 and add one until the end, then start at public int CPUcol() { if (currentcol < numcol-1) { currentcol++; else { currentcol = 0; return currentcol;

SampleApp.java. Page 1

SampleApp.java. Page 1 SampleApp.java 1 package msoe.se2030.sequence; 2 3 /** 4 * This app creates a UI and processes data 5 * @author hornick 6 */ 7 public class SampleApp { 8 private UserInterface ui; // the UI for this program

More information

CSE143 - Project 3A Turn-in Receipt

CSE143 - Project 3A Turn-in Receipt 1 of 9 11/24/2003 4:24 PM CSE143 - Project 3A Turn-in Receipt Prins, Ryan Michael (rprins@u.washington.edu) Section AD Daniel Wyatt Turn-in logged at 16:24:36 PST, Monday, Nov 24, 2003 Your program compiled

More information

CIT 590 Homework 10 Battleship

CIT 590 Homework 10 Battleship CIT 590 Homework 10 Battleship Purposes of this assignment: To give you more experience with classes and inheritance General Idea of the Assignment Once again, this assignment is based on a game, since

More information

A sample print out is: is is -11 key entered was: w

A sample print out is: is is -11 key entered was: w Lab 9 Lesson 9-2: Exercise 1, 2 and 3: Note: when you run this you may need to maximize the window. The modified buttonhandler is: private static class ButtonListener implements ActionListener public void

More information

AP CS Unit 11: Graphics and Events

AP CS Unit 11: Graphics and Events AP CS Unit 11: Graphics and Events This packet shows how to create programs with a graphical interface in a way that is consistent with the approach used in the Elevens program. Copy the following two

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSIY SCHOOL O COMPUING CMPE212, ALL ERM, 2011 INAL EXAMINAION 15 December 2011, 2pm, Grant Hall Instructor: Alan McLeod HAND IN Answers Are Recorded on Question Paper SOLUION If the instructor

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan

More information

package solution; import battleship.battleship; import battleship.cellstate; import java.awt.point; import java.util.arraylist;

package solution; import battleship.battleship; import battleship.cellstate; import java.awt.point; import java.util.arraylist; package solution; import battleship.battleship; import battleship.cellstate; import java.awt.point; import java.util.arraylist; * @author Salah Abuzaid 000348604 public class SampleBot { public int gamesize;

More information

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) M257 MTA Spring2010 Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks) 1. If we need various objects that are similar in structure, but

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:

More information

RAIK 183H Examination 2 Solution. November 10, 2014

RAIK 183H Examination 2 Solution. November 10, 2014 RAIK 183H Examination 2 Solution November 10, 2014 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)

More information

Exception Handling CSCI 201 Principles of Software Development

Exception Handling CSCI 201 Principles of Software Development Exception Handling CSCI 201 Principles of Software Development Jeffrey Miller, Ph.D. jeffrey.miller@usc.edu Outline Program USC CSCI 201L 2/19 Exception Handling An exception is an indication of a problem

More information

// autor igre Ivan Programerska sekcija package mine;

// autor igre Ivan Programerska sekcija package mine; // autor igre Ivan Bauk @ Programerska sekcija package mine; import java.awt.color; import java.awt.flowlayout; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener;

More information

File IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20

File IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20 File IO Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 I/O Package Overview Package java.io Core concept: streams Ordered sequences of data that have a source

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod If the

More information

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Page 1 of 16 HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2005 FINAL EXAMINATION 9am to 12noon, 19 DECEMBER 2005 Instructor: Alan McLeod If

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Solution HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2009 FINAL EXAMINATION 7pm to 10pm, 18 APRIL 2009, Dunning Hall Instructor: Alan McLeod

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. Solution HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC124, WINTER TERM, 2010 FINAL EXAMINATION 2pm to 5pm, 19 APRIL 2010, Dunning Hall Instructor: Alan McLeod

More information

Mobile Application Programming: ios

Mobile Application Programming: ios Mobile Application Programming: ios CS4962 Fall 2014 Project 4 - Network MVC Battleship Due: 11:59PM Monday, Nov 17 Abstract Build a Model-View-Controller implementation of the game Battleship on Android.

More information

Midterm assessment - MAKEUP Fall 2010

Midterm assessment - MAKEUP Fall 2010 M257 MTA Faculty of Computer Studies Information Technology and Computing Date: /1/2011 Duration: 60 minutes 1-Version 1 M 257: Putting Java to Work Midterm assessment - MAKEUP Fall 2010 Student Name:

More information

Do not turn to the next page until the start of the exam.

Do not turn to the next page until the start of the exam. Principles of Java Language with Applications, PIC20a E. Ryu Winter 2017 Final Exam Monday, March 20, 2017 3 hours, 8 questions, 100 points, 11 pages While we don t expect you will need more space than

More information

CS159 Midterm #1 Review

CS159 Midterm #1 Review Name: CS159 Midterm #1 Review 1. Choose the best answer for each of the following multiple choice questions. (a) What is the effect of declaring a class member to be static? It means that the member cannot

More information

/* Write a Program implementing GUI based Calculator using Swing */

/* Write a Program implementing GUI based Calculator using Swing */ /* Write a Program implementing GUI based Calculator using Swing */ import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.*; public class Calculator extends JFrame

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 2 2 Develop the layout of those elements 3 3 Add listeners to the elements 9 4 Implement custom drawing 12 1 The StringArt Program To illustrate

More information

COMP16121 Sample Code Lecture 1

COMP16121 Sample Code Lecture 1 COMP16121 Sample Code Lecture 1 Sean Bechhofer, University of Manchester, Manchester, UK sean.bechhofer@manchester.ac.uk 1 SimpleFrame 1 import javax.swing.jframe; 2 3 public class SimpleFrame { 4 5 /*

More information

Example: Building a Java GUI

Example: Building a Java GUI Steven Zeil October 25, 2013 Contents 1 Develop the Model 3 2 Develop the layout of those elements 4 3 Add listeners to the elements 12 4 Implement custom drawing 15 1 The StringArt Program To illustrate

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview

More information

RAIK 183H Examination 2 Solution. November 11, 2013

RAIK 183H Examination 2 Solution. November 11, 2013 RAIK 183H Examination 2 Solution November 11, 2013 Name: NUID: This examination consists of 5 questions and you have 110 minutes to complete the test. Show all steps (including any computations/explanations)

More information

General Certificate of Education Advanced Subsidiary Examination June 2010

General Certificate of Education Advanced Subsidiary Examination June 2010 General Certificate of Education Advanced Subsidiary Examination June 2010 Computing COMP1/PM/JA Unit 1 Problem Solving, Programming, Data Representation and Practical Exercise Preliminary Material A copy

More information

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:

Lecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features: Lecture 28 Exceptions and Inner Classes Goals We are going to talk in more detail about two advanced Java features: Exceptions supply Java s error handling mechanism. Inner classes ease the overhead of

More information

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015 CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 6 problems on the following 6 pages. You may use your double- sided hand- written 8 ½ x 11 note sheet

More information

COMP16121 Notes on Mock Exam Questions

COMP16121 Notes on Mock Exam Questions COMP16121 Notes on Mock Exam Questions December 2016 Mock Exam Attached you will find a Mock multiple choice question (MCQ) exam for COMP16121, to assist you in preparing for the actual COMP16121 MCQ Exam

More information

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM Introduction to the Assignment In this lab, you will finish the program to allow a user to solve Sudoku puzzles.

More information

Project 1 - Battleship Game

Project 1 - Battleship Game Project 1 - Battleship Game Minimal Submission Due: Friday, December 22 th, 2006 Revision History Final Project Due: Sunday, January 21 th, 2007 Dec 7th, 2006, v1.0: Initial revision for faculty review.

More information

ArrayList, Hashtables, Exceptions, and Files

ArrayList, Hashtables, Exceptions, and Files ArrayList, Hashtables, Exceptions, and Files Course Evaluations in Miverva ArrayList java.util.arraylist This is one of the Java implementations of a LinkedList. I.e. an ArrayList does not have a fixed

More information

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4.

Virtualians.ning.pk. 2 - Java program code is compiled into form called 1. Machine code 2. native Code 3. Byte Code (From Lectuer # 2) 4. 1 - What if the main method is declared as private? 1. The program does not compile 2. The program compiles but does not run 3. The program compiles and runs properly ( From Lectuer # 2) 4. The program

More information

Input from Files. Buffered Reader

Input from Files. Buffered Reader Input from Files Buffered Reader Input from files is always text. You can convert it to ints using Integer.parseInt() We use BufferedReaders to minimize the number of reads to the file. The Buffer reads

More information

IT 313 Advanced Application Development Midterm Exam

IT 313 Advanced Application Development Midterm Exam Page 1 of 9 February 12, 2019 IT 313 Advanced Application Development Midterm Exam Name Part A. Multiple Choice Questions. Circle the letter of the correct answer for each question. Optional: supply a

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2011 FINAL EXAMINATION 7pm to 10pm, 26 APRIL 2011, Ross Gym Instructor: Alan McLeod If the instructor

More information

Advanced Java Unit 6: Review of Graphics and Events

Advanced Java Unit 6: Review of Graphics and Events Advanced Java Unit 6: Review of Graphics and Events This is a review of the basics of writing a java program that has a graphical interface. To keep things simple, all of the graphics programs will follow

More information

DM537 Object-Oriented Programming. Peter Schneider-Kamp.

DM537 Object-Oriented Programming. Peter Schneider-Kamp. DM537 Object-Oriented Programming Peter Schneider-Kamp petersk@imada.sdu.dk! http://imada.sdu.dk/~petersk/dm537/! TYPE CASTS & FILES & EXCEPTION HANDLING 2 Type Conversion Java uses type casts for converting

More information

PART1: Choose the correct answer and write it on the answer sheet:

PART1: Choose the correct answer and write it on the answer sheet: PART1: Choose the correct answer and write it on the answer sheet: (15 marks 20 minutes) 1. Which of the following is included in Java SDK? a. Java interpreter c. Java disassembler b. Java debugger d.

More information

Recitation: Loop Jul 7, 2008

Recitation: Loop Jul 7, 2008 Nested Loop Recitation: Loop Jul 7, 2008 1. What is the output of the following program? Use pen and paper only. The output is: ****** ***** **** *** ** * 2. Test this program in your computer 3. Use "for

More information

Answer on question #61311, Programming & Computer Science / Java

Answer on question #61311, Programming & Computer Science / Java Answer on question #61311, Programming & Computer Science / Java JSP JSF for completion Once the user starts the thread by clicking a button, the program must choose a random image out of an image array,

More information

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

JRadioButton account_type_radio_button2 = new JRadioButton(Current); ButtonGroup account_type_button_group = new ButtonGroup(); Q)Write a program to design an interface containing fields User ID, Password and Account type, and buttons login, cancel, edit by mixing border layout and flow layout. Add events handling to the button

More information

Mobile Application Programming: Android

Mobile Application Programming: Android Mobile Application Programming: Android CS4530 Fall 2016 Project 4 - Networked Battleship Due: 11:59PM Monday, Nov 7th Abstract Extend your Model-View-Controller implementation of the game Battleship on

More information

Do not turn to the next page until the start of the exam.

Do not turn to the next page until the start of the exam. Principles of Java Language with Applications, PIC20a E. Ryu Fall 2017 Final Exam Monday, December 11, 2017 3 hours, 8 questions, 100 points, 9 pages While we don t expect you will need more space than

More information

CS 180 Final Exam Review 12/(11, 12)/08

CS 180 Final Exam Review 12/(11, 12)/08 CS 180 Final Exam Review 12/(11, 12)/08 Announcements Final Exam Thursday, 18 th December, 10:20 am 12:20 pm in PHYS 112 Format 30 multiple choice questions 5 programming questions More stress on topics

More information

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } }

class BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } } 9.12) public interface Filter boolean accept(object x); Describes any class whose objects can measure other objects. public interface Measurer double measure(object anobject); This program tests the use

More information

Name: CSC143 Exam 1 1 CSC 143. Exam 1. Write also your name in the appropriate box of the scantron

Name: CSC143 Exam 1 1 CSC 143. Exam 1. Write also your name in the appropriate box of the scantron Name: CSC143 Exam 1 1 CSC 143 Exam 1 Write also your name in the appropriate box of the scantron Name: CSC143 Exam 1 2 Multiple Choice Questions (30 points) Answer all of the following questions. READ

More information

Course overview: Introduction to programming concepts

Course overview: Introduction to programming concepts Course overview: Introduction to programming concepts What is a program? The Java programming language First steps in programming Program statements and data Designing programs. This part will give an

More information

So You Want to Build a Burp Plugin?

So You Want to Build a Burp Plugin? So You Want to Build a Burp Plugin? Monika Morrow, Senior Security Consultant at AppSec Consulting Inc. December 6, 2013 Why Burp Plugins? Eliminate annoyances Status notifications, default settings, auto-scope

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, FALL TERM, 2013 FINAL EXAMINATION 7pm to 10pm, 18 DECEMBER 2013 Instructor: Alan McLeod If the instructor

More information

CS 209 Programming in Java #10 Exception Handling

CS 209 Programming in Java #10 Exception Handling CS 209 Programming in Java #10 Exception Handling Textbook Chapter 15 Spring, 2006 Instructor: J.G. Neal 1 Topics What is an Exception? Exception Handling Fundamentals Errors and Exceptions The try-catch-finally

More information

Section Basic graphics

Section Basic graphics Chapter 16 - GUI Section 16.1 - Basic graphics Java supports a set of objects for developing graphical applications. A graphical application is a program that displays drawings and other graphical objects.

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CISC124, WINTER TERM, 2012 FINAL EXAMINATION 9am to 12pm, 26 APRIL 2012 Instructor: Alan McLeod If the instructor is

More information

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau List of Slides 1 Title 2 Chapter 13: Graphical user interfaces 3 Chapter aims 4 Section 2: Example:Hello world with a GUI 5 Aim 6 Hello world with a GUI 7 Hello world with a GUI 8 Package: java.awt and

More information

Lecture 5: Java Graphics

Lecture 5: Java Graphics Lecture 5: Java Graphics CS 62 Spring 2019 William Devanny & Alexandra Papoutsaki 1 New Unit Overview Graphical User Interfaces (GUI) Components, e.g., JButton, JTextField, JSlider, JChooser, Containers,

More information

Full file at

Full file at Chapter 1 Primitive Java Weiss 4 th Edition Solutions to Exercises (US Version) 1.1 Key Concepts and How To Teach Them This chapter introduces primitive features of Java found in all languages such as

More information

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Systems Programming Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Leganés, 21st of March, 2014. Duration: 75 min. Full

More information

Lecture 11 (review session for intro to computing) ============================================================== (Big-Oh notation continued)

Lecture 11 (review session for intro to computing) ============================================================== (Big-Oh notation continued) Lecture 11 (review session for intro to computing) 1) (Big-Oh notation continued) Assume that each of the following operations takes 1 time unit: an arithmetic op, a comparison, a logical op, an assignment,

More information

CS 201, Fall 2016 Sep 28th Exam 1

CS 201, Fall 2016 Sep 28th Exam 1 CS 201, Fall 2016 Sep 28th Exam 1 Name: Question 1. [5 points] Write code to prompt the user to enter her age, and then based on the age entered, print one of the following messages. If the age is greater

More information

Lab 11. A sample of the class is:

Lab 11. A sample of the class is: Lab 11 Lesson 11-2: Exercise 1 Exercise 2 A sample of the class is: public class List // Methods public void store(int item) values[length] = item; length++; public void printlist() // Post: If the list

More information

CMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2

CMP-326 Exam 2 Spring 2018 Solutions Question 1. Version 1. Version 2 Question 1 30 30 60 60 90 20 20 40 40 60 Question 2 a. b. public Song(String title, String artist, int length, String composer) { this.title = title; this.artist = artist; this.length = length; this.composer

More information

FirstSwingFrame.java Page 1 of 1

FirstSwingFrame.java Page 1 of 1 FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import

More information

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS Glossary of Terms 2-4 Step by Step Instructions 4-7 HWApp 8 HWFrame 9 Never trust a computer

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction

CSC 160 LAB 8-1 DIGITAL PICTURE FRAME. 1. Introduction CSC 160 LAB 8-1 DIGITAL PICTURE FRAME PROFESSOR GODFREY MUGANDA DEPARTMENT OF COMPUTER SCIENCE 1. Introduction Download and unzip the images folder from the course website. The folder contains 28 images

More information

COMP Assignment #10 (Due: Monday, March 11:30pm)

COMP Assignment #10 (Due: Monday, March 11:30pm) COMP1406 - Assignment #10 (Due: Monday, March 31st @ 11:30pm) In this assignment you will practice using recursion with data structures. (1) Consider the following BinaryTree class: public class BinaryTree

More information

CN208 Introduction to Computer Programming

CN208 Introduction to Computer Programming CN208 Introduction to Computer Programming Lecture #11 Streams (Continued) Pimarn Apipattanamontre Email: pimarn@pimarn.com 1 The Object Class The Object class is the direct or indirect superclass of every

More information

protected void printserial() { System.out.println("> NO." + this.serialno); this.serialno++; }

protected void printserial() { System.out.println(> NO. + this.serialno); this.serialno++; } NumberedTicketGenerator.java package j2.exam.ex01; public abstract class NumberedTicketGenerator { protected int serialno; public NumberedTicketGenerator() { super(); this.serialno = 1000; public void

More information

import javax.swing.*; import java.awt.*; import java.awt.event.*;

import javax.swing.*; import java.awt.*; import java.awt.event.*; I need to be walked through with why the stocks are being recognized "half way." They will print out in the console but won't be recognized by certain code. Every line of code seems to look right and that's

More information

Graphical User Interfaces 2

Graphical User Interfaces 2 Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2014 2011 Extending JFrame Dialog boxes Overview Ge

More information

Introduction This assignment will ask that you write a simple graphical user interface (GUI).

Introduction This assignment will ask that you write a simple graphical user interface (GUI). Computing and Information Systems/Creative Computing University of London International Programmes 2910220: Graphical Object-Oriented and Internet programming in Java Coursework one 2011-12 Introduction

More information

Project MineSweeper Collaboration: Solo Complete this Project by yourself or with help from Section Leaders and Rick You are asked to write the non-graphical user interface aspects of the popular game

More information

import java.applet.applet; import java.applet.audioclip; import java.net.url; public class Vjesala2 {

import java.applet.applet; import java.applet.audioclip; import java.net.url; public class Vjesala2 { import java.awt.color; import java.awt.flowlayout; import java.awt.font; import java.awt.gridlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton;

More information

Window Interfaces Using Swing Objects

Window Interfaces Using Swing Objects Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs

More information

PIC 20A GUI with swing

PIC 20A GUI with swing PIC 20A GUI with swing Ernest Ryu UCLA Mathematics Last edited: November 22, 2017 Hello swing Let s create a JFrame. import javax. swing.*; public class Test { public static void main ( String [] args

More information

Simple Data Source Crawler Plugin to Set the Document Title

Simple Data Source Crawler Plugin to Set the Document Title Simple Data Source Crawler Plugin to Set the Document Title IBM Content Analytics 1 Contents Introduction... 4 Basic FS Crawler behavior.... 8 Using the Customizer Filter to Modify the title Field... 13

More information

I/O STREAM (REQUIRED IN THE FINAL)

I/O STREAM (REQUIRED IN THE FINAL) I/O STREAM (REQUIRED IN THE FINAL) STREAM A stream is a communication channel that a program has with the outside world. It is used to transfer data items in succession. An Input/Output (I/O) Stream represents

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. QUEEN'S UNIVERSITY SCHOOL OF COMPUTING HAND IN Answers Are Recorded on Question Paper CMPE212, FALL TERM, 2012 FINAL EXAMINATION 18 December 2012, 2pm Instructor: Alan McLeod If the instructor is unavailable

More information

Dr. Hikmat A. M. AbdelJaber

Dr. Hikmat A. M. AbdelJaber Dr. Hikmat A. M. AbdelJaber JWindow: is a window without a title bar or move controls. The program can move and resize it, but the user cannot. It has no border at all. It optionally has a parent JFrame.

More information

Come & Join Us at VUSTUDENTS.net

Come & Join Us at VUSTUDENTS.net Come & Join Us at VUSTUDENTS.net For Assignment Solution, GDB, Online Quizzes, Helping Study material, Past Solved Papers, Solved MCQs, Current Papers, E-Books & more. Go to http://www.vustudents.net and

More information

Theoritical run times

Theoritical run times Touches of n Theoritical run times 2.5E+11 2E+11 1.5E+11 1E+11 5E+10 0 52 1304 1323 1889 5915 5934 Array length (n) Figure 1 cities A data structure containing all cities result list of cities in order

More information

Based on slides by Prof. Burton Ma

Based on slides by Prof. Burton Ma Based on slides by Prof. Burton Ma 1 TV - on : boolean - channel : int - volume : int + power(boolean) : void + channel(int) : void + volume(int) : void Model View Controller RemoteControl + togglepower()

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2007 FINAL EXAMINATION 7pm to 10pm, 10 DECEMBER 2007, Jeffery Hall Instructor: Alan McLeod If the

More information

Simple File Input And Output

Simple File Input And Output Simple File Input And Output Types of Java Files Simple File Output in Java Simple File Input in Java Writing and reading objects to and from file (by implementing the Serializable interface) Storing Information

More information

Java Programming. Atul Prakash

Java Programming. Atul Prakash Java Programming Atul Prakash Java Language Fundamentals The language syntax is similar to C/ C++ If you know C/C++, you will have no trouble understanding Java s syntax If you don't, it will be easier

More information

Informatik II. Andreas Bärtschi, Andreea Ciuprina, Felix Friedrich, Patrick Gruntz, Hermann Lehner, Max Rossmannek, Chris Wendler FS 2018

Informatik II. Andreas Bärtschi, Andreea Ciuprina, Felix Friedrich, Patrick Gruntz, Hermann Lehner, Max Rossmannek, Chris Wendler FS 2018 1 Informatik II Übung 4 Andreas Bärtschi, Andreea Ciuprina, Felix Friedrich, Patrick Gruntz, Hermann Lehner, Max Rossmannek, Chris Wendler FS 2018 Program Today 2 1 Feedback of last exercise 2 Repetition

More information

CSPP : Introduction to Object-Oriented Programming

CSPP : Introduction to Object-Oriented Programming CSPP 511-01: Introduction to Object-Oriented Programming Harri Hakula Ryerson 256, tel. 773-702-8584 hhakula@cs.uchicago.edu August 7, 2000 CSPP 511-01: Lecture 15, August 7, 2000 1 Exceptions Files: Text

More information

Programming with the SCA BB Service Configuration API

Programming with the SCA BB Service Configuration API CHAPTER 3 Programming with the SCA BB Service Configuration API Published: December 23, 2013, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration

More information

Exceptions and Error Handling

Exceptions and Error Handling Exceptions and Error Handling Michael Brockway January 16, 2015 Some causes of failures Incorrect implementation does not meet the specification. Inappropriate object request invalid index. Inconsistent

More information

Programming with the SCA BB Service Configuration API

Programming with the SCA BB Service Configuration API CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: September 17, 2012, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration

More information

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split DAFTAR LAMPIRAN Source Code Java Aplikasi Keyword to Image Renamer Split Source Code Menu Utama package spin_text; import java.awt.color; import java.awt.event.actionevent; import java.awt.event.actionlistener;

More information

CS Week 11. Jim Williams, PhD

CS Week 11. Jim Williams, PhD CS 200 - Week 11 Jim Williams, PhD This Week 1. Exam 2 - Thursday 2. Team Lab: Exceptions, Paths, Command Line 3. Review: Muddiest Point 4. Lecture: File Input and Output Objectives 1. Describe a text

More information

Practice exam for CMSC131-04, Fall 2017

Practice exam for CMSC131-04, Fall 2017 Practice exam for CMSC131-04, Fall 2017 Q1 makepalindrome - Relevant topics: arrays, loops Write a method makepalidrome that takes an int array, return a new int array that contains the values from the

More information

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written. SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2008 FINAL EXAMINATION 7pm to 10pm, 17 DECEMBER 2008, Grant Hall Instructor: Alan McLeod

More information

Programming with the SCA BB Service Configuration API

Programming with the SCA BB Service Configuration API CHAPTER 3 Programming with the SCA BB Service Configuration API Revised: November 8, 2010, Introduction This chapter is a reference for the main classes and methods of the Cisco SCA BB Service Configuration

More information