AP COMPUTER SCIENCE A 2007 SCORING GUIDELINES



Similar documents
Iteration CHAPTER 6. Topic Summary

COSC 111: Computer Programming I. Dr. Bowen Hui University of Bri>sh Columbia Okanagan

AP Computer Science A 2012 Scoring Guidelines

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

AP Computer Science A 2010 Scoring Guidelines

Curriculum Map. Discipline: Computer Science Course: C++

Part I. Multiple Choice Questions (2 points each):

3 Pillars of Object-oriented Programming. Industrial Programming Systems Programming & Scripting. Extending the Example.

6.088 Intro to C/C++ Day 4: Object-oriented programming in C++ Eunsuk Kang and Jean Yang

Roulette: Inheritance Case Study

AP CALCULUS AB 2009 SCORING GUIDELINES

Building Java Programs

Facebook Twitter YouTube Google Plus Website

Complement. If A is an event, then the complement of A, written A c, means all the possible outcomes that are not in A.

CS 111 Classes I 1. Software Organization View to this point:

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

AP CALCULUS AB 2007 SCORING GUIDELINES (Form B)

AP CALCULUS AB 2009 SCORING GUIDELINES

CmpSci 187: Programming with Data Structures Spring 2015

java Features Version April 19, 2013 by Thorsten Kracht

Yosemite National Park, California. CSE 114 Computer Science I Inheritance

We have put together this beginners guide to sports betting to help you through your first foray into the betting world.

Reading Input From A File

Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A

Training Manual. Shuffle Master Gaming Three Card Poker Training Manual R

Software Engineering Techniques

Computer Programming I

Guidelines for Creating Reports

Part 3: GridWorld Classes and Interfaces

Inheritance, overloading and overriding

Hash Tables. Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Data Dictionary Revisited

Java Interview Questions and Answers

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

AP Computer Science A 2011 Free-Response Questions

Introductory programming course: motivating students with prior knowledge

The C Programming Language course syllabus associate level

GENERATION OF EPC BASED SIMULATION MODELS. EURO 2012 Vilnius, Lithuania

1 Hour, Closed Notes, Browser open to Java API docs is OK

澳 門 彩 票 有 限 公 司 SLOT Sociedade de Lotarias e Apostas Mútuas de Macau, Lda. Soccer Bet Types

Install Java Development Kit (JDK) 1.8

C++FA 5.1 PRACTICE MID-TERM EXAM

Term Project: Roulette

Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts

Meeting the requirements of the Care Certificate is a challenge for all employers of health and social care support workers.

Accounting Games and Hands-on Activities. By Linda Welsh, Business Educator Whitehall High School

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

Java Classes. GEEN163 Introduction to Computer Programming

Chapter 13 - Inheritance

AP Computer Science Java Subset

SSC - Communication and Networking Java Socket Programming (II)

The resulting tile cannot merge with another tile again in the same move. When a 2048 tile is created, the player wins.

CSE 308. Coding Conventions. Reference

Building Java Programs

CSS 543 Program 3: Online Tic-Tac-Toe Game Professor: Munehiro Fukuda Due date: see the syllabus

CS193j, Stanford Handout #10 OOP 3

Instance Creation. Chapter

C++ Overloading, Constructors, Assignment operator

Conditionals: (Coding with Cards)

J a v a Quiz (Unit 3, Test 0 Practice)

Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is

Lab 9. Spam, Spam, Spam. Handout 11 CSCI 134: Spring, To gain experience with Strings. Objective

AP CALCULUS AB 2006 SCORING GUIDELINES (Form B) Question 4

Elementary Statistics and Inference. Elementary Statistics and Inference. 17 Expected Value and Standard Error. 22S:025 or 7P:025.

Chulalongkorn University International School of Engineering Department of Computer Engineering Computer Programming Lab.

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

AP Computer Science A 2004 Free-Response Questions

Topic 11 Scanner object, conditional execution

Programming to Interfaces

Introduction to: Computers & Programming: Review for Midterm 2

CSE 1020 Introduction to Computer Science I A sample nal exam

7.1 Our Current Model

AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities

CSC 221: Computer Programming I. Fall 2011

Elementary Statistics and Inference. Elementary Statistics and Inference. 16 The Law of Averages (cont.) 22S:025 or 7P:025.

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

Building Java Programs

Software Engineering 1 EEL5881 Spring Homework - 2

AP PSYCHOLOGY 2013 SCORING GUIDELINES

Problem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class

AP CALCULUS AB 2006 SCORING GUIDELINES. Question 4

GAME CONDITIONS Implementation: July 23, Lottery Corporation Inc. ("ALC") and shall apply to the ibingo lottery scheme until amended by ALC.

Example Hand Say you are dealt the following cards: Suits Suits are ranked in the following order.

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

JAVA.UTIL.SCANNER CLASS

Abstract Classes. Suppose we want write a program that manipulates various types of bank accounts. An Account typically has following features;

GridWorld AP Computer Science Case Study. Solutions Manual

CS506 Web Design and Development Solved Online Quiz No. 01

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT

An Incomplete C++ Primer. University of Wyoming MA 5310

Fruit Machine. Level. Activity Checklist Follow these INSTRUCTIONS one by one. Test Your Project Click on the green flag to TEST your code

Table of Contents. LESSON: The JUnit Test Tool...1. Subjects...2. Testing What JUnit Provides...4. JUnit Concepts...5

Soccer Bet Types Content

3 Improving the Crab more sophisticated programming

Python Programming: An Introduction To Computer Science

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Transcription:

AP COMPUTER SCIENCE A 2007 SCORING GUIDELINES Question 4: Game Design (Design) Part A: RandomPlayer 4 points +1/2 class RandomPlayer extends Player +1 constructor +1/2 public RandomPlayer(String aname) +1/2 super(aname) +2 1/2 getnextmove +1/2 state.getcurrentmoves() +1 if no moves +1/2 test if size = 0 +1/2 return "no move" only if 0 moves +1 if moves +1/2 select random move index +1/2 return random move Part B: play 5 points +1/2 print initial state (OK to print in loop) +3 make repeated moves +1 repeat until state.isgameover() +1/2 state.getcurrentplayer() +1/2 player.getnextmove(state) +1/2 display player and move +1/2 make move +1 1/2 determine winner +1/2 state.getwinner() +1/2 display message if draw (if getwinner returns null) lose both if done +1/2 display message if winner before game ends 2007 The College Board. All rights reserved.

AP COMPUTER SCIENCE A 2007 CANONICAL SOLUTIONS Question 4: Game Design (Design) PART A: public class RandomPlayer extends Player { public RandomPlayer(String aname) { super(aname); public String getnextmove(gamestate state) { ArrayList<String> possiblemoves = state.getcurrentmoves(); if (possiblemoves.size() == 0) { return "no move"; else { int randomindex = (int)(math.random()*possiblemoves.size()); return possiblemoves.get(randomindex); PART B: public void play() { System.out.println("Initial state:" + state); while (!state.isgameover()) { Player currplayer = state.getcurrentplayer(); String currmove = currplayer.getnextmove(state); System.out.println(currPlayer.getName() + ": " + currmove); state.makemove(currmove); Player winner = state.getwinner(); if (winner!= null) { System.out.println(winner.getName() + " wins"); else { System.out.println("Game ends in a draw"); 2007 The College Board. All rights reserved.

AP COMPUTER SCIENCE A 2007 SCORING COMMENTARY Question 4 Overview This question centered on abstraction, class design, and inheritance. Students were provided with an abstract framework for representing different types of games, including a GameState interface for capturing the state of a particular game and a Player class for representing a game player. In part (a) students were required to extend Player by designing and implementing a RandomPlayer class that always selects its move at random. This involved knowing the syntax of inheritance and also recognizing which methods needed to be overridden. Overriding the getnextmove method required calling the getcurrentmoves method defined by the GameState interface, randomly selecting a move (if one exists), and returning that move. In part (b) students were required to implement the play method of a GameDriver class, which calls the appropriate GameState and Player methods to alternate player moves until the game is over. Sample: A4a Score: 8½ For part (a) of this solution, the code includes the proper class header as well as the correct constructor header. The constructor includes a correct call to super. The getnextmove method properly locates the current moves that are possible and checks to see if there are any possible moves. It then correctly returns either no move or a randomly selected move. The solution earned all 4 points available for this portion of the question. In part (b) the solution properly prints the state of the game. Both the loop and the call to getcurrentplayer are correct. The call to getnextmove is incorrect because it is missing the parameter (state), so this part of the solution lost ½ point. The display of the player s name and move works as requested, and the move is made correctly. The getwinner method is properly called and checked and the correct message is printed, so all the remaining points were awarded for this solution. Sample: A4b Score: 5½ The solution for part (a) includes the proper class header and constructor header but is missing the call to super() so it lost that ½ point. The getnextmove method properly locates the current moves that are possible and checks to see if there are any possible moves. It then returns either no move or a randomly selected move. The ½ point for random was lost because of the missing parameter on the call to nextint. The student was awarded 3 of the 4 possible points for this part of the question. In part (b) the code properly prints the state of the game. Because the call to isgameover is incorrectly implemented (it must be called on the state object) the solution lost the 1 point awarded for this check. The current player is properly accessed and earned that ½ point. The student attempts to reimplement the getnextmove method, so the getnextmove, display, and makemove credit was lost. The getwinner method is properly called and checked, and the correct message is printed, so the last three ½ points were earned. For this part the student earned 2½ out of 5 possible points. 2007 The College Board. All rights reserved.

AP COMPUTER SCIENCE A 2007 SCORING COMMENTARY Question 4 (continued) Sample: A4c Score: 1½ Part (a) of this student s solution includes the proper class header and earned that ½ point, but the constructor header is incorrect and there is no call to super(), which lost the credit given for those actions. The method getnextmove does not properly locate the current moves that are possible. The check for false is not the correct way to determine whether the number of moves is 0, but the correct message is returned if no moves are available earning that ½ point. The remaining code does not fit the question requirements, so the solution earned no additional credit. Part (a) earned 1 out of 4 possible points. Part (b) properly prints the state of the game and earned that ½ point but earned no further credit for this part of the question. There is no loop, no call to getcurrentplayer, no call to getnextmove (instead the method is reimplemented), no call to makemove (again the method is reimplemented), and the test for a win is incorrect. For this part the student earned ½ point out of 5 possible points. 2007 The College Board. All rights reserved.