Core Competency DOO (Design Object-Oriented)

Size: px
Start display at page:

Download "Core Competency DOO (Design Object-Oriented)"

Transcription

1 Here is the documentation for the rest of the semester. This document includes specification of the remaining Core Competencies, specifications for the final two Core Labs, and specifications for a number of Enhanced Labs from which you will pick just a few to complete. Note that there are only two more Core Labs, along with a bunch of Enhanced Labs from which you can pick the ones you choose to do. The new Enhanced Labs are not worth very many lab points, but the more you do, the better prepared you will be for the Final Exam, taking CS 2050, and actually using what you learn in this course for some future purpose even if you don t take any more computer science courses. No sections of the Zybook beyond Chapter 6 are assigned for credit, but you will want to read some parts of the Zybook as detailed in the following. Core Competency DOO (Design Object-Oriented) Given an English description of a scenario, be able to identify the different classes involved, and for each class, be able to figure out what instance variables it should have, be able to write code for each instance variable including appropriate data type and name, and be able to figure out what instance methods the class should have. An answer will be considered correct if it shows understanding of the ideas we won t require all the members to be identified, just some. Sample Problem: Suppose you are writing a program to computerize the game of Risk. Here is a simplified description of the game. Risk is a simulation of international warfare. The world is organized into 42 countries. Each country has a name, some other countries that border it, and a continent that it belongs to. Also, each country has to have at least one army on it, and typically has a bunch more. And, at all times each country is owned by some player. When a player destroys all the armies on a country owned by another player, that player takes ownership of the country. Players take turns in order (first, second, third, fourth, first, etc.). Each player owns some countries. When battles take place (decided by throwing dice), one or two armies sometimes need to be removed from a country. When a player s turn is about to start, they get some new armies (depending on how many and which countries they own) that they can place on any of the countries they own. At the end of a player s turn, they get to move any number of armies across a single border from one of their countries to another of their countries. CS 1050 Spring 2018 Page 74

2 Here is one reasonable answer to this problem: public class Country { private String name; // name of the country private int numarmies; // number of armies on that country private ArrayList<Country> neighbors; // list of countries connected // to this country private Player owner; // the current owner of this country // rough headers for some instance methods: public void addarmies(int num) public void removearmies(int num) public void changeowner(player p) public class Player { private int turn; // holds 1, 2, 3, 4,... private ArrayList<Country> owned; // holds list of owned countries // rough headers for some instance methods: public int computearmiesearned() public void conquer(country c) Practice Problem: (to be done in class working in small groups) In the game of Monopoly (if you have any questions about the rules of this game, ask your group members), one very important kind of object is the lot. Given the title deed for a few lot instances, perform Core Competency DOO on the class Lot. Write your answer on a whiteboard in preparation for whole group discussion. You will also identify other classes that would be needed in this game, because they are needed as the type of a Lot instance variable or as a parameter type in a Lot instance method. Core Competency WMH (Write Method Headers) Given method calls, with enough context to pin down the types of the arguments and the return type, infer the most likely method header, with arbitrary parameter names. Sample Problem: (headers already shown off to the right below) For the fragment of code below, write down after each method call the most appropriate corresponding method header, including static or not, correct return type, method name, and parameter list (use whatever names you like for the parameters, but the types must be appropriate): Assume that all the methods being called are members of the Clown class. CS 1050 Spring 2018 Page 75

3 Ball a, b; Clown c, d, e; double x, y, z; // lots of code omitted that gives these variables meaningful values c = new Clown( 13.2, "Bozo" ); ----> Clown(double x, String s) z = f(x); ----> double f(double x) e = Clown.flip( c, d ); ----> static Clown flip(clown x, Clown y) b = c.flib( b, d ); ----> Ball flib(ball b, Clown d) d.foop(); ----> void foop() x = e.mop( 37.0, a ); ----> double mop(double a, Ball b) Practice Problem: For the fragment of code below, write down to the right of each method call the most appropriate corresponding method header, including static or not, correct return type, method name, and parameter list (use whatever names you like for the parameters, but the types must be appropriate). Assume that all the methods (including constructors) being called are members of the Dog class. Dog x, y; Food r, s, t; Cat a, b; int result; // lots of code omitted that gives these variables meaningful values x = new Dog( 17.2, "Rowdy" ); ----> r = x.produce(); ----> result = Dog.torment( a, b ); ----> x.chase( a, y ); ----> CS 1050 Spring 2018 Page 76

4 Core Competency WMB (Write Method Bodies) Given an English description of a new kind of object, with specified behaviors, code for the instance variables in the class, and headers for the constructor(s) and instance methods, write the bodies of the constructor(s) and instance methods. Scenario: Suppose you want to implement a Java class that holds information for a student in a course. Specifically, suppose that a student has a name and scores on three tests as whole number values representing the percentage score on each test. Write the bodies for all the constructors and instance methods as documented in the file Student.java, using the given instance variables. Answer for this Core Competency: Practice Problem: Scenario: public class Bottle { See the class Student.java in the Labs folder we will answer this problem as a whole group during class-time. Suppose we are starting work on a program for a game where players try to fill and empty various bottles. We figure out that a bottle has two instance variables how much it can hold (its capacity ) and how much it currently holds (its volume ). Write the bodies (off to the side with arrows showing where the code should be inserted) for all the constructors and instance methods as documented, using the given instance variables. // instance variables: private int cap; private int vol; // construct a new bottle with // default capacity 12, // assuming that a new bottle starts empty public Bottle() { // construct a new bottle with the given capacity // c, assuming that a new bottle starts empty public Bottle(int c) { CS 1050 Spring 2018 Page 77

5 // add the given amount to the volume of this // bottle, except don t go past the capacity public void add(int amount) { // empty this bottle and return the // volume it had public int empty() { // transfer the volume in this bottle to the // other bottle, not exceeding its capacity, // and empty this bottle public void transferto(bottle other) { // Bottle Core Lab 13.1 [2 lab points] The purpose of this Lab is to give you some hands-on experience with the try-catch exception mechanism in Java. See Section 13.1 (and later sections if you are interested) in the Zybook Here are the basics of exceptions: Many method calls in Java classes throw exceptions. If you look in the Java API at one such, say the method parseint in the Integer class, you will see throws NumberFormatException as part of its header. If a method throws an exception, you have to handle it somehow. By far the best way is to use a try-catch statement around the method call so the possible exception can be handled right there (as opposed to putting throws Exception in the header of all the methods in the chain leading to the one that throws the exception). Here is the basic template for a try-catch statement: try { // put code here that includes the method call that can // throw an exception // if an exception is thrown, execution jumps below to // the corresponding catch block CS 1050 Spring 2018 Page 78

6 catch (Exception e) { // put code here to report the problem // or otherwise handle it For example, see lines in the Noteboard.java file in the folder Noteboard in the folder Session18Shultz. Download the file LabCh13GetInt.java and write the body of the method getint so that it behaves as documented in the file and the test case below. Hints: your getint method will have a while loop with a try-catch statement in its body. This is a good place to use a boolean flag variable, say named done, to exit the loop. Test your code by running LabCh13GetInt and repeatedly typing whatever nonsense you like when the program asks you to enter an integer value. When you finally type a legal int value, the program should compute and display its square. Here is a sample run, with the user inputs shown in italic font:. Enter an integer to be squared: two Error, please enter a legal int: 2 3 Error, please enter a legal int: 2.7 Error, please enter a legal int: 2 The square is 4.. Core Lab 7.1 [4 lab points] In this Lab you will create a bank simulation starting from scratch. This will give you hands-on experience with object-based features of Java, use of ArrayList, and review of pretty much everything in the course. See your instructor s examples (the Noteboard application for Professor Shultz and the Staff applications for Professor Kramer) of applications that load a bunch of objects from a data file into an ArrayList, allow the user to interactively modify individual objects and the list, and save the list to a data file when the user wants to quit. You will need to make two classes for this Lab. The ATM class simulates the behavior of a simple automatic teller machine. The Account class encapsulates the behavior of. CS 1050 Spring 2018 Page 79

7 a single customer s account. The ATM class should have as its core instance variables an ArrayList<Account> instance, known as list in the following specifications, and an integer index current holding the location in list of the current account, if there is one, or 1 if there is no current account. You will get to practice designing a class with instance variables, instance methods, and constructors as you create the Account class. Your first step will be to figure out the instance variables for the Account class, like in the upcoming Core Competency DOO (Design Object-Oriented). Your main method in the ATM class will load information from a data file into list. (you will have to create the initial file). Then it will use the pattern as in Core Competency WML (write menu loop) to let the user interactively issue a series of commands. Finally, it will save the current list back to the data file. You can use whatever data file name you prefer. At the top of the loop a menu showing the possible commands should be displayed, along with the name of the current account or a statement that there is no current account. Here are the specifications for the commands to be implemented in the menu-loop (for user convenience, some of the commands are short): Command Mnemonic Actions q quit Ask for the managerial password, and if the input matches the managerial password, save the account data to the data file and halt the program. If the user doesn t enter the correct managerial password, display an appropriate error message. n new account Ask the user for the password they want to use (any string), and for the initial deposit they are making in their savings account (the checking account starts at $0). Find the next available account number and construct a new Account instance with the obvious data. Display on-screen a welcome message telling the customer their account number and asking them to memorize it. The new account should be set as the current account, in case the customer wants to do some transactions. CS 1050 Spring 2018 Page 80

8 Command Mnemonic Actions i login Ask for an account number (a positive integer). If there is no account in the list with that account number, display an error message. Otherwise, ask for the password for that account. If the password matches the account password, make this account the current account. Otherwise, display an error message and leave the current account unchanged. Note: at the beginning, or after the current account is logged out, the current account location should be set to 1 to signify that there is no current account. After logging in successfully, the current account location is set to the index of that account in the list. All of the commands below should display an error message rather than doing what is described if there is no current account. o log out Set the current account location to 1. ws withdraw savings Ask the user for an amount to withdraw from savings. If the amount is reasonable (positive and not bigger than the savings balance), reduce the savings balance by that amount and display the new balance; otherwise display an error message. wc withdraw checking Same as ws but with the checking account of the current account. CS 1050 Spring 2018 Page 81

9 Command Mnemonic Actions ds deposit savings Ask the user for an amount to deposit to savings. If the amount is positive, increase the savings balance by that amount and display the new balance; otherwise display an error message. dc deposit checking Same as ds but with the checking account. t transfer Ask the user for an amount to transfer from savings to checking, and if the amount is reasonable, transfer it and display the new balances; otherwise display error message. c close account Display a message showing the total funds being given to the user due to account closure, and then remove the current account from list. After this current should be set to 1. You should use your getint method from Core Lab 13.1 (copy and paste it into the ATM class) to obtain all monetary amounts as integer numbers of dollars. You can choose whatever managerial password you wish. Be sure to thoroughly test your application before asking to have it checked. Be sure to test all the things that should produce error messages, and all the transactions. Be sure to have at least five accounts in your testing. CS 1050 Spring 2018 Page 82

Remaining Enhanced Labs

Remaining Enhanced Labs Here are some announcements regarding the end of the semester, and the specifications for the last Enhanced Labs. Don t forget that you need to take the Common Final Examination on Saturday, May 5, from

More information

Session 14 March 31, 2018

Session 14 March 31, 2018 Notes: Session 13 (2/28) and Session 15 (3/7) are catch up Sessions. This document contains documentation for the next group of Core Competencies, including practice problems that you should work. We will

More information

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class CS112 Lecture: Defining Classes Last revised 2/3/06 Objectives: 1. To describe the process of defining an instantiable class Materials: 1. BlueJ SavingsAccount example project 2. Handout of code for SavingsAccount

More information

EXAM Computer Science 1 Part 1

EXAM Computer Science 1 Part 1 Maastricht University Faculty of Humanities and Science Department of Knowledge Engineering EXAM Computer Science 1 Part 1 Block 1.1: Computer Science 1 Code: KEN1120 Examiner: Kurt Driessens Date: Januari

More information

Array Based Lists. Collections

Array Based Lists. Collections Array Based Lists Reading: RS Chapter 15 1 Collections Data structures stores elements in a manner that makes it easy for a client to work with the elements Specific collections are specialized for particular

More information

CSCI 355 LAB #2 Spring 2004

CSCI 355 LAB #2 Spring 2004 CSCI 355 LAB #2 Spring 2004 More Java Objectives: 1. To explore several Unix commands for displaying information about processes. 2. To explore some differences between Java and C++. 3. To write Java applications

More information

CIS 162 Project 4 Farkle (a dice game)

CIS 162 Project 4 Farkle (a dice game) CIS 162 Project 4 Farkle (a dice game) Due Date at the start of class on Monday, 3 December (be prepared for quick demo and zybook test) Before Starting the Project Read chapter 10 (ArrayList) and 13 (arrays)

More information

Midterm Exam 2 CS 455, Spring 2011

Midterm Exam 2 CS 455, Spring 2011 Name: USC loginid (e.g., ttrojan): Midterm Exam 2 CS 455, Spring 2011 March 31, 2011 There are 6 problems on the exam, with 50 points total available. There are 7 pages to the exam, including this one;

More information

Object- Oriented Analysis, Design and Programming

Object- Oriented Analysis, Design and Programming Object- Oriented Analysis, Design and Programming Medialogy, Semester 4 Monday 19 April 2010 9.00 12.00 You have 3 hours to complete this examination. Neither written material nor electronic equipment

More information

int main() { int account = 100; // Pretend we have $100 in our account int withdrawal;

int main() { int account = 100; // Pretend we have $100 in our account int withdrawal; Introduction to Exceptions An exception is an abnormal condition that occurs during the execution of a program. For example, divisions by zero, accessing an invalid array index, or ing to convert a letter

More information

CSE 142 Su01 Final Exam Sample Solution page 1 of 7

CSE 142 Su01 Final Exam Sample Solution page 1 of 7 CSE 142 Su01 Final Exam Sample Solution page 1 of 7 Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the space provided on these pages. Budget your time so you

More information

CSCI 355 Lab #2 Spring 2007

CSCI 355 Lab #2 Spring 2007 CSCI 355 Lab #2 Spring 2007 More Java Objectives: 1. To explore several Unix commands for displaying information about processes. 2. To explore some differences between Java and C++. 3. To write Java applications

More information

CIS 110 Spring 2014 Introduction to Computer Programming 12 May 2014 Final Exam Answer Key

CIS 110 Spring 2014 Introduction to Computer Programming 12 May 2014 Final Exam Answer Key CIS 110 Spring 2014 Final Exam 1 CIS 110 Spring 2014 Introduction to Computer Programming 12 May 2014 Final Exam Answer Key 0.) THE EASY ONE (1 point total) Check coversheet for name, recitation #, PennKey,

More information

CS112 Lecture: Defining Instantiable Classes

CS112 Lecture: Defining Instantiable Classes CS112 Lecture: Defining Instantiable Classes Last revised 2/3/05 Objectives: 1. To describe the process of defining an instantiable class 2. To discuss public and private visibility modifiers. Materials:

More information

CS2102, D15 Exam 1. Name:

CS2102, D15 Exam 1. Name: CS2102, D15 Exam 1 Name: You have 50 minutes to complete the problems on the following pages. There should be sufficient space provided for your answers. If a problem asks you to create a class hierarchy,

More information

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle

CS211 Computers and Programming Matthew Harris and Alexa Sharp July 9, Boggle Boggle If you are not familiar with the game Boggle, the game is played with 16 dice that have letters on all faces. The dice are randomly deposited into a four-by-four grid so that the players see the

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

Practice Midterm Examination

Practice Midterm Examination Steve Cooper Handout #28 CS106A May 1, 2013 Practice Midterm Examination Midterm Time: Tuesday, May 7, 7:00P.M. 9:00P.M. Portions of this handout by Eric Roberts and Patrick Young This handout is intended

More information

Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018

Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018 CS18 Integrated Introduction to Computer Science Fisler, Nelson Contents Lab 2: Object-Oriented Design 12:00 PM, Jan 31, 2018 1 Terminology 1 2 Class Hierarchy Diagrams 2 2.1 An Example: Animals...................................

More information

CS107 Handout 37 Spring 2007 May 25, 2007 Introduction to Inheritance

CS107 Handout 37 Spring 2007 May 25, 2007 Introduction to Inheritance CS107 Handout 37 Spring 2007 May 25, 2007 Introduction to Inheritance Handout written by Julie Zelenski, updated by Jerry. Inheritance is a language property most gracefully supported by the object-oriented

More information

Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently.

Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently. Project 1 Computer Science 2334 Spring 2016 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple movie data system. Milestones: 1. Use

More information

The Hong Kong Polytechnic University

The Hong Kong Polytechnic University COMP1001-Problem Solving in IT Top-Down Design Objective: Upon completion of this lab, you will be able to: How to use top down design to design an Automatic teller machine (ATM) Structure of Top-Down

More information

CS 116 Week 8 Page 1

CS 116 Week 8 Page 1 CS 116 Week 8: Outline Reading: 1. Dale, Chapter 11 2. Dale, Lab 11 Objectives: 1. Mid-term exam CS 116 Week 8 Page 1 CS 116 Week 8: Lecture Outline 1. Mid-term Exam CS 116 Week 8 Page 2 CS 116 Week 8:

More information

CIS 121 Data Structures and Algorithms with Java Spring 2018

CIS 121 Data Structures and Algorithms with Java Spring 2018 CIS 121 Data Structures and Algorithms with Java Spring 2018 Homework 2 Thursday, January 18 Due Monday, January 29 by 11:59 PM 7 Required Problems (85 points), and Style and Tests (15 points) DO NOT modify

More information

CS 455 Midterm Exam 1 Fall 2010 [Bono] Sept. 29, 2010

CS 455 Midterm Exam 1 Fall 2010 [Bono] Sept. 29, 2010 Name: USC loginid (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2010 [Bono] Sept. 29, 2010 There are 4 problems on the exam, with 55 points total available. There are 7 pages to the exam, including this

More information

UNDERSTANDING CLASS DEFINITIONS CITS1001

UNDERSTANDING CLASS DEFINITIONS CITS1001 UNDERSTANDING CLASS DEFINITIONS CITS1001 Main concepts to be covered Fields / Attributes Constructors Methods Parameters Source ppts: Objects First with Java - A Practical Introduction using BlueJ, David

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists

ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists ASSIGNMENT 5 Data Structures, Files, Exceptions, and To-Do Lists COMP-202B, Winter 2009, All Sections Due: Tuesday, April 14, 2009 (23:55) You MUST do this assignment individually and, unless otherwise

More information

An Introduction to Subtyping

An Introduction to Subtyping An Introduction to Subtyping Type systems are to me the most interesting aspect of modern programming languages. Subtyping is an important notion that is helpful for describing and reasoning about type

More information

Defensive Programming

Defensive Programming Defensive Programming Software Engineering CITS1220 Based on the Java1200 Lecture notes by Gordon Royle Lecture Outline Why program defensively? Encapsulation Access Restrictions Documentation Unchecked

More information

CS 211 Programming Practicum Fall 2018

CS 211 Programming Practicum Fall 2018 Due: Wednesday, 11/7/18 at 11:59 pm Infix Expression Evaluator Programming Project 5 For this lab, write a C++ program that will evaluate an infix expression. The algorithm REQUIRED for this program will

More information

Objectives: 1. Introduce the course. 2. Define programming 3. Introduce fundamental concepts of OO: object, class

Objectives: 1. Introduce the course. 2. Define programming 3. Introduce fundamental concepts of OO: object, class CS112 Lecture: Course Introduction Last revised 1/3/06 Objectives: 1. Introduce the course. 2. Define programming 3. Introduce fundamental concepts of OO: object, class Materials: 1. Questionnaire 2. Syllabi

More information

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions CSE1720 Click to edit Master Week text 01, styles Lecture 02 Second level Third level Fourth level Fifth level Winter 2015! Thursday, Jan 8, 2015 1 Objectives for this class meeting 1. Conduct review of

More information

The ArrayList class CSC 123 Fall 2018 Howard Rosenthal

The ArrayList class CSC 123 Fall 2018 Howard Rosenthal The ArrayList class CSC 123 Fall 2018 Howard Rosenthal Lesson Goals Describe the ArrayList class Discuss important methods of this class Describe how it can be used in modeling Much of the information

More information

Classwork 7: Craps. N. Duong & R. Rodriguez, Java Crash Course January 6, 2015

Classwork 7: Craps. N. Duong & R. Rodriguez, Java Crash Course January 6, 2015 Classwork 7: Craps N. Duong & R. Rodriguez, Java Crash Course January 6, 2015 For this classwork, you will be writing code for the game Craps. For those of you who do not know, Craps is a dice-rolling

More information

SEMESTER 1, 2011 EXAMINATIONS. CITS1200 Java Programming FAMILY NAME: GIVEN NAMES:

SEMESTER 1, 2011 EXAMINATIONS. CITS1200 Java Programming FAMILY NAME: GIVEN NAMES: Computer Science & Software Engineering SEMESTER 1, 2011 EXAMINATIONS CITS1200 Java Programming FAMILY NAME: GIVEN NAMES: STUDENT ID: SIGNATURE: This Paper Contains: 26 pages (including title page) Time

More information

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003 1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to

More information

The University of Melbourne Department of Computer Science and Software Engineering Software Design Semester 2, 2003

The University of Melbourne Department of Computer Science and Software Engineering Software Design Semester 2, 2003 The University of Melbourne Department of Computer Science and Software Engineering 433-254 Software Design Semester 2, 2003 Answers for Tutorial 7 Week 8 1. What are exceptions and how are they handled

More information

CMSC 201 Spring 2018 Project 3 Minesweeper

CMSC 201 Spring 2018 Project 3 Minesweeper CMSC 201 Spring 2018 Project 3 Minesweeper Assignment: Project 3 Minesweeper Due Date: Design Document: Friday, May 4th, 2018 by 8:59:59 PM Project: Friday, May 11th, 2018 by 8:59:59 PM Value: 80 points

More information

Software Design and Analysis for Engineers

Software Design and Analysis for Engineers Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:

More information

CS 455 Final Exam Fall 2013 [Bono] December 12, 2013

CS 455 Final Exam Fall 2013 [Bono] December 12, 2013 Name: USC loginid (e.g., ttrojan): CS 455 Final Exam Fall 2013 [Bono] December 12, 2013 There are 9 problems on the exam, with 64 points total available. There are 7 pages to the exam, including this one;

More information

Assignment 5: Part 1 (COMPLETE) Sprites on a Plane

Assignment 5: Part 1 (COMPLETE) Sprites on a Plane Assignment 5: Part 1 (COMPLETE) Sprites on a Plane COMP-202B, Winter 2011, All Sections Due: Wednesday, April 6, 2011 (13:00) This assignment comes in TWO parts. Part 2 of the assignment will be published

More information

Outline for Today CSE 142. Programming a Teller Machine. CSE142 Wi03 I-1. ATM Algorithm for Dispensing Money

Outline for Today CSE 142. Programming a Teller Machine. CSE142 Wi03 I-1. ATM Algorithm for Dispensing Money CSE 142 Outline for Today Iteration repeating operations Iteration in Java while statement Shorthand for definite (counting) iterations for statement Nested loops Iteration Introduction to Loops 1/10/2003

More information

An exception is simply an error. Instead of saying an error occurred, we say that an.

An exception is simply an error. Instead of saying an error occurred, we say that an. 3-1 An exception is simply an error. Instead of saying an error occurred, we say that an. Suppose we have a chain of methods. The method is the first in the chain. An expression in it calls some other

More information

1 Inheritance (8 minutes, 9 points)

1 Inheritance (8 minutes, 9 points) Name: Career Account ID: Recitation#: 1 CS180 Spring 2011 Exam 2, 6 April, 2011 Prof. Chris Clifton Turn Off Your Cell Phone. Use of any electronic device during the test is prohibited. Time will be tight.

More information

Computer Sciences 302 Exam 2 Information & Sample Exam

Computer Sciences 302 Exam 2 Information & Sample Exam Computer Sciences 302 Exam 2 Information & Sample Exam Below you ll find information about the second midterm exam and sample exam questions. This sample is intended to be similar in length and difficulty

More information

Lab 1: Setup 12:00 PM, Sep 10, 2017

Lab 1: Setup 12:00 PM, Sep 10, 2017 CS17 Integrated Introduction to Computer Science Hughes Lab 1: Setup 12:00 PM, Sep 10, 2017 Contents 1 Your friendly lab TAs 1 2 Pair programming 1 3 Welcome to lab 2 4 The file system 2 5 Intro to terminal

More information

CMPSCI 187 / Spring 2015 Hangman

CMPSCI 187 / Spring 2015 Hangman CMPSCI 187 / Spring 2015 Hangman Due on February 12, 2015, 8:30 a.m. Marc Liberatore and John Ridgway Morrill I N375 Section 01 @ 10:00 Section 02 @ 08:30 1 CMPSCI 187 / Spring 2015 Hangman Contents Overview

More information

CS 455 Midterm Exam 1 Fall 2010 [Bono] Sept. 29, 2010

CS 455 Midterm Exam 1 Fall 2010 [Bono] Sept. 29, 2010 SOLUTION Name: USC loginid (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2010 [Bono] Sept. 29, 2010 There are 4 problems on the exam, with 55 points total available. There are 7 pages to the exam, including

More information

Dartmouth College Computer Science 10, Winter 2012 Final Exam

Dartmouth College Computer Science 10, Winter 2012 Final Exam Dartmouth College Computer Science 10, Winter 2012 Final Exam Professor Drysdale Print your name: If you need more space to answer a question than we give you, you may use the backs of pages or you may

More information

Lab ACN : C++ Programming Exercises

Lab ACN : C++ Programming Exercises Lab ACN : C++ Programming Exercises ------------------------------------------------------------------------------------------------------------------- Exercise 1 Write a temperature conversion program

More information

CS2102, B11 Exam 2. Name:

CS2102, B11 Exam 2. Name: CS2102, B11 Exam 2 Name: You have 50 minutes to complete the problems on the following pages. There should be sufficient space provided for your answers. If a problem asks you to create an interface, you

More information

CS 1302 Chapter 9 (Review) Object & Classes

CS 1302 Chapter 9 (Review) Object & Classes CS 1302 Chapter 9 (Review) Object & Classes Reference Sections 9.2-9.5, 9.7-9.14 9.2 Defining Classes for Objects 1. A class is a blueprint (or template) for creating objects. A class defines the state

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

Interlude. Object Oriented Design

Interlude. Object Oriented Design Interlude Object Oriented Design Announcements for This Lecture This Week Today is an Interlude Nothing today is on exam Another Big Picture talk Relevant to Assignment 6 Review for exam posted New Review

More information

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader

Prelim 1 Solutions. CS 2110, March 10, 2015, 5:30 PM Total Question True False. Loop Invariants Max Score Grader Prelim 1 Solutions CS 2110, March 10, 2015, 5:30 PM 1 2 3 4 5 Total Question True False Short Answer Recursion Object Oriented Loop Invariants Max 20 15 20 25 20 100 Score Grader The exam is closed book

More information

Part III Appendices 165

Part III Appendices 165 Part III Appendices 165 Appendix A Technical Instructions Learning Outcomes This material will help you learn how to use the software you need to do your work in this course. You won t be tested on it.

More information

COS 126 Written Exam 2 (Spring 2015)

COS 126 Written Exam 2 (Spring 2015) COS 126 Written Exam 2 (Spring 2015) There are 8 questions on this exam, weighted as indicated below. This exam is closed book. You may use a single-page two-sided hand-written cheatsheet. There is a blank

More information

Outline. Announcements. Homework 2. Boolean expressions 10/12/2007. Announcements Homework 2 questions. Boolean expression

Outline. Announcements. Homework 2. Boolean expressions 10/12/2007. Announcements Homework 2 questions. Boolean expression Outline ECS 10 10/8 Announcements Homework 2 questions Boolean expressions If/else statements State variables and avoiding sys.exit( ) Example: Coin flipping (if time permits) Announcements Professor Amenta

More information

CS 307 Midterm 2 Spring 2008

CS 307 Midterm 2 Spring 2008 Points off 1 2 3 4 Total off Net Score Exam Number: CS 307 Midterm 2 Spring 2008 Name UTEID login name TA's Name: Mario Ruchica Vishvas (Circle One) Instructions: 1. Please turn off your cell phones and

More information

CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017

CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017 Name: USC NetID (e.g., ttrojan): CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017 There are 6 problems on the exam, with 62 points total available. There are 10 pages to the exam (5 pages double-sided),

More information

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer Prelim 1 CS 2110, March 15, 2016, 5:30 PM 0 1 2 3 4 5 Total Question Name True False Short Answer Object- Oriented Recursion Loop Invariants Max 1 20 14 25 19 21 100 Score Grader The exam is closed book

More information

Project 3: Implementing a List Map

Project 3: Implementing a List Map Project 3: Implementing a List Map CSCI 245 Programming II: Object-Oriented Design Spring 2017 Devin J. Pohly (adapted from Thomas VanDrunen) This project has two main goals: To give you practice in implementing

More information

CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016

CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016 Name: USC NetID (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016 There are 5 problems on the exam, with 56 points total available. There are 10 pages to the exam (5 pages

More information

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently. User Request: Create a simple magazine data system. Milestones:

More information

CS61B Lecture #7. Announcements:

CS61B Lecture #7. Announcements: Announcements: CS61B Lecture #7 New discussion section: Tuesday 2 3PM in 310 Soda. New lab section: Thursday 2 4PM in 273 Soda. Programming Contest coming up: 5 October (new date). Watch for details. Last

More information

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing

More information

CS61B Lecture #5: Arrays and Objects

CS61B Lecture #5: Arrays and Objects CS61B Lecture #5: Arrays and Objects For faster response, please send urgent problems (like the lab files don t compile ) as mail to cs61b, rather than using class messages. Homeworks are generally due

More information

CS201 - Assignment 3, Part 2 Due: Wednesday March 5, at the beginning of class

CS201 - Assignment 3, Part 2 Due: Wednesday March 5, at the beginning of class CS201 - Assignment 3, Part 2 Due: Wednesday March 5, at the beginning of class For this assignment we will be developing a text-based Tic Tac Toe game 1. The key to this assignment is that we re going

More information

Programming a Bank Database. We ll store the information in two tables: INTEGER DECIMAL(10, 2)

Programming a Bank Database. We ll store the information in two tables: INTEGER DECIMAL(10, 2) WE1 W o r k e d E x a m p l e 2 2.1 Programming a Bank Database In this Worked Example, we will develop a complete database program. We will reimplement the ATM simulation of Chapter 12, storing the customer

More information

Mutating Object State and Implementing Equality

Mutating Object State and Implementing Equality Mutating Object State and Implementing Equality 6.1 Mutating Object State Goals Today we touch the void... (sounds creepy right... see the movie, or read the book, to understand how scary the void can

More information

WES-CS GROUP MEETING #9

WES-CS GROUP MEETING #9 WES-CS GROUP MEETING #9 Exercise 1: Practice Multiple-Choice Questions 1. What is output when the following code executes? String S1 = new String("hello"); String S2 = S1 +! ; S1 = S1 + S1; System.out.println(S1);

More information

EXAMINATIONS 2012 END-OF-YEAR SWEN222. Software Design. Question Topic Marks 1. Design Quality Design Patterns Design by Contract 12

EXAMINATIONS 2012 END-OF-YEAR SWEN222. Software Design. Question Topic Marks 1. Design Quality Design Patterns Design by Contract 12 T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:..................... EXAMINATIONS 2012 END-OF-YEAR SWEN222 Software Design Time

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 60 0 DEPARTMENT OF INFORMATION TECHNOLOGY QUESTION BANK III SEMESTER CS89- Object Oriented Programming Regulation 07 Academic Year 08 9 Prepared

More information

CPS122 Lecture: Defining a Class

CPS122 Lecture: Defining a Class Objectives: CPS122 Lecture: Defining a Class last revised January 14, 2016 1. To introduce structure of a Java class 2. To introduce the different kinds of Java variables (instance, class, parameter, local)

More information

About this exam review

About this exam review Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review

More information

Chapter 3. Iteration

Chapter 3. Iteration Chapter 3 Iteration Iteration Iteration is the form of program control that allows us to repeat a section of code. For this reason this form of control is often also referred to as repetition. The programming

More information

CSE 142 Sp02 Final Exam Version A Page 1 of 14

CSE 142 Sp02 Final Exam Version A Page 1 of 14 CSE 142 Sp02 Final Exam Version A Page 1 of 14 Basic reference information about collection classes that you may find useful when answering some of the questions. Methods common to all collection classes

More information

CS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012

CS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012 Name: USC loginid (e.g., ttrojan): CS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012 There are 6 problems on the exam, with 70 points total available. There are 7 pages to the exam, including this one;

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

Ascending. Load. Descending. Save. Exit. Numbers

Ascending. Load. Descending. Save. Exit. Numbers 1. Create an abstract class shape. Derive three classes sphere, cone and cylinder from it. Calculate area and volume of all (use method overriding) [30] 2. Design an HTML page containing 4 option buttons

More information

Review Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous

Review Chapter 6 in Bravaco. Short Answers 1. This type of method does not return a value. a. null b. void c. empty d. anonymous Assignment 3 Methods Review CSC 123 Fall 2018 Notes: All homework must be submitted via e-mail. All parts of assignment must be submitted in a single e-mail with multiple attachments when required. Notes:

More information

CS 134 Programming Exercise 9:

CS 134 Programming Exercise 9: CS 134 Programming Exercise 9: Nibbles Objective: To gain experience working with 2 dimensional arrays. The Problem Nibbles is a snake. Nibbles moves around a field, looking for food. Unfortunately, Nibbles

More information

Soda Machine Laboratory

Soda Machine Laboratory Soda Machine Laboratory Introduction This laboratory is intended to give you experience working with multiple queue structures in a familiar real-world setting. The given application models a soda machine

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

Lists using ArrayList

Lists using ArrayList Lists using ArrayList 1 ArrayList One of the drawbacks of arrays is that they do not make it easy to accommodate collections of arbitrary size. We have to commit ourselves to a fixed size when we introduce

More information

METHODS EXERCISES GuessNumber and Sample run SumAll Sample Run

METHODS EXERCISES GuessNumber and Sample run SumAll Sample Run METHODS EXERCISES Write a method called GuessNumber that receives nothing and returns back nothing. The method first picks a random number from 1-100. The user then keeps guessing as long as their guess

More information

Introduction to Java Programs for Packet #4: Classes and Objects

Introduction to Java Programs for Packet #4: Classes and Objects Introduction to Java Programs for Packet #4: Classes and Objects Note. All of these programs involve writing and using more than one class file. 1. Copy the Box class and compile it. But you won t be able

More information

CS 455 Midterm Exam 1 Spring 2013 [Bono] Feb. 21, 2013

CS 455 Midterm Exam 1 Spring 2013 [Bono] Feb. 21, 2013 Name: USC loginid (e.g., ttrojan): CS 455 Midterm Exam 1 Spring 2013 [Bono] Feb. 21, 2013 There are 5 problems on the exam, with 54 points total available. There are 7 pages to the exam, including this

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Programming Project 1

Programming Project 1 Programming Project 1 Handout 6 CSCI 134: Fall, 2016 Guidelines A programming project is a laboratory that you complete on your own, without the help of others. It is a form of take-home exam. You may

More information

Object-oriented Programming and Software Engineering CITS1001. Multiple-choice Mid-semester Test

Object-oriented Programming and Software Engineering CITS1001. Multiple-choice Mid-semester Test Object-oriented Programming and Software Engineering CITS1001 Multiple-choice Mid-semester Test Semester 1, 2015 Mark your solutions on the provided answer page, by filling in the appropriate circles.

More information

Java Puzzle Ball Nick Ristuccia

Java Puzzle Ball Nick Ristuccia Java Puzzle Ball Nick Ristuccia Lesson 4-3 Editing Java Code Lab 4: Finish the Banking GUI Application The Lab Instructions are available on the Lesson 4 page of the MOOC. This is an enhanced version of

More information

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 10/e Copyright 1992-2015 by Pearson Education, Inc. All Rights Reserved. Data structures Collections of related data items. Discussed in depth in Chapters 16 21. Array objects Data

More information

CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015

CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015 Name: USC netid (e.g., ttrojan): CS 455 Midterm Exam 1 Fall 2015 [Bono] Thursday, Oct. 1, 2015 There are 5 problems on the exam, with 58 points total available. There are 10 pages to the exam (5 pages

More information

CSE 143: Computer Programming II Spring 2015 HW7: 20 Questions (due Thursday, May 28, :30pm)

CSE 143: Computer Programming II Spring 2015 HW7: 20 Questions (due Thursday, May 28, :30pm) CSE 143: Computer Programming II Spring 2015 HW7: 20 Questions (due Thursday, May 28, 2015 11:30pm) This program focuses on binary trees and recursion. Turn in the following files using the link on the

More information

LINKED LISTS cs2420 Introduction to Algorithms and Data Structures Spring 2015

LINKED LISTS cs2420 Introduction to Algorithms and Data Structures Spring 2015 LINKED LISTS cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -assignment 5 due tonight at midnight -assignment 6 is out -YOU WILL BE SWITCHING PARTNERS! 3 assignment

More information

Second Examination Solution

Second Examination Solution University of Illinois at Urbana-Champaign Department of Computer Science Second Examination Solution CS 225 Data Structures and Software Principles Fall 2007 7p-9p, Thursday, November 8 Name: NetID: Lab

More information

ArrayList. Introduction. java.util.arraylist

ArrayList. Introduction. java.util.arraylist ArrayList Introduction In this article from my free Java 8 course, I will be giving you a basic overview of the Java class java.util.arraylist. I will first explain the meaning of size and capacity of

More information

ASSIGNMENT 5 Objects, Files, and a Music Player

ASSIGNMENT 5 Objects, Files, and a Music Player ASSIGNMENT 5 Objects, Files, and a Music Player COMP-202A, Fall 2009, All Sections Due: Thursday, December 3, 2009 (23:55) You MUST do this assignment individually and, unless otherwise specified, you

More information