© A+ Computer Science - Elevens is a lab about classes and Lists. List is a major concept being tested by the Elevens lab. Elevens.

Slides:



Advertisements
Similar presentations
1 Greg Wilson BA 4234 CSC407: Software Architecture Fall 2006 Refactoring.
Advertisements

Java Coding 8 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Object-Oriented Design Example - The.
Classes and Objects. What is Design? The parts of the software including – what information each part holds – what things each part can do – how the various.
Using Classes to Store Data Computer Science 2 Gerb.
Design Example. Requirements Make a program that simulates the game of blackjack For now, we ignore money/betting…. just simulate game play But… this.
Elevens Lab Student Material – on website
AP Computer Science.  Not necessary but good programming practice in Java  When you override a super class method notation.
© A+ Computer Science - ArrayList © A+ Computer Science - Lab 16.
o Simulate a deck of playing cards o Shuffle the deck o Deal (5) cards into the hand o Turn over the first card o The user must guess whether the next.
o Simulate a deck of playing cards o Shuffle the deck o Deal 5 cards into the hand o Turn over the first card o The user must guess whether the next card.
© A+ Computer Science - Inheritance © A+ Computer Science - Lab 20.
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
GCOC – A.P. Computer Science A. College Board Topics – A.P. Computer Science A Program Design - Read and understand a problem's description, purpose,
Interfaces. –An interface describes a set of methods: no constructors no instance variables –The interface must be implemented by some class. 646 java.
© A+ Computer Science - public Triangle() { setSides(0,0,0); } Constructors are similar to methods. Constructors set the properties.
How to do well on the AP CS Free Response Questions
© A+ Computer Science - Chicken yeller = new Chicken();
© A+ Computer Science - A queue is a group of same-type values. Values are added to the back of a queue and removed from the front.
© A+ Computer Science - Which of the following statements assigns the letter S to the third row and first column of a two-dimensional.
Designing a Card Game Solitaire--Thirteens. Game.
This recitation 1 An interesting point about A3: Using previous methods to avoid work in programming and debugging. How much time did you spend writing.
1 CSC 221: Computer Programming I Fall 2006 Lists, data storage & access  ArrayList class  methods: add, get, size, remove, contains, set, indexOf, toString.
College Board Topics – A.P. Computer Science A Program Design - Read and understand a problem's description, purpose, and goals; Apply data abstraction.
AP Computer Science A – Healdsburg High School 1 Unit 9 - Parameter Passing in Java.
How to do well on the AP CS Free Response Questions
© A+ Computer Science - In Java, any variable that refers to an Object is a reference variable. The variable stores the memory.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
COMP 14 Introduction to Programming Mr. Joshua Stough March 23, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
© A+ Computer Science - Visit us at Full Curriculum Solutions M/C Review Question Banks.
AP Java Elevens Lab.
Objects as a programming concept
Objects as a programming concept
Game Extras Pepper.
Chapter 5 Black Jack.
Interfaces I once attended a Java user group meeting where James Gosling (Java's inventor) was the featured speaker. During the memorable Q&A session,
Top Ten Words that Almost Rhyme with “Peas”
Topic 7 Interfaces I once attended a Java user group meeting where James Gosling (one of Java's creators) was the featured speaker. During the memorable.
A+ Computer Science AP Review 2018 AP CS A EXAM
CS 302 Week 10 Jim Williams.
CSC240 Computer Science III
Multiple Choice -answer the easiest question 1st
Properties 7: Properties Programming C# © 2003 DevelopMentor, Inc.
© A+ Computer Science - Arrays and Lists © A+ Computer Science -
Implementing Classes Chapter 3.
Example with Static Variable
The Matrix A b a d e a a a a a a a A b a d e a a a a a a a
Methods Copying Autoboxing
© A+ Computer Science - OOP Pieces © A+ Computer Science -
Truth tables: Ways to organize results of Boolean expressions.
See requirements for practice program on next slide.
Task 2 Implementation help
Instance Method – CSC142 Computer Science II
Take out a piece of paper and PEN.
CIS 199 Final Review.
CS 200 Creating Classes Jim Williams, PhD.
Take out a piece of paper and PEN.
A+ Computer Science PARAMETERS
Program: Mini Phone Book 2/11/2016
A+ Computer Science AP Review 2019 AP CS A EXAM
What is a String? String s = "compsci"; s c o m p s i
First Semester Review.
CSC 205 Java Programming II
Presentation transcript:

© A+ Computer Science -

Elevens is a lab about classes and Lists. List is a major concept being tested by the Elevens lab. Elevens is a multi-class project that uses a Card and Deck class to simulate the playing of cards.

© A+ Computer Science - For Elevens, you must understand the basics of classes and Lists. Building a class with instance variables, constructors, and methods is step 1.

© A+ Computer Science - public class Dog { private int age; private String name; public Dog( String n, int a ) { age = a; name = n; } public int getAge() { return age; } public String getName() { return name; } public String toString() { return "Dog - " + name + " " + age; }

© A+ Computer Science -

For Elevens, you also understand Lists and how to store items in a list. ArrayList is the class that will be used to store Card reference. ArrayList has many method that can be used to add and remove items.

© A+ Computer Science - ArrayList frequently used methods NameUse add(item)adds item to the end of the list add(spot,item)adds item at spot – shifts items up-> set(spot,item)put item at spot z[spot]=item get(spot)returns the item at spot return z[spot] size()returns the # of items in the list remove()removes an item from the list clear()removes all items from the list import java.util.ArrayList;

© A+ Computer Science - List ray; ray = new ArrayList (); ray.add("hello"); ray.add("whoot"); ray.add("contests"); out.println(ray.get(0).substring(0, 1)); out.println(ray.get(2).substring(0,1)); ray stores String references. OUTPUT h c

© A+ Computer Science -

Taking a class and loading instances of that class into a List is required for this project and to be successful on the AP CS A exam. The List concept must be isolated and mastered before attempting to build any type of real Card game.

© A+ Computer Science - public class Dog { private int age; private String name; public Dog( String n, int a ) { age = a; name = n; } public int getAge() { return age; } public String getName() { return name; } public String toString() { return "Dog - " + name + " " + age; }

© A+ Computer Science - List ray; ray = new ArrayList (); ray.add( new Dog( "fred", 11) ); ray.add( new Dog( "ann", 21) ); System.out.println( ray ); OUTPUT [Dog - fred 11, Dog - ann 21]

© A+ Computer Science - ray.add( new Dog( "fred", 11) ); ray.add( new Dog( "ann", 21) ); ray.add( new Dog( "bob", 4) ); ray0x120x320xD Dog 11 Dog 21 Dog 4

© A+ Computer Science -

Elevens is a lab about classes and Lists. Elevens involves making Cards, a Deck, Players, a Dealer, and a game. Any card game involving multi-classes using Cards, a Deck, and Players would illustrate the concepts in Elevens.

© A+ Computer Science - public class Card { public static final String FACES[] = {"ZERO","ACE","TWO","THREE","FOUR“, "FIVE","SIX","SEVEN","EIGHT","NINE","TEN","JACK","QUEEN","KING"}; //instance variables private String suit; private int face; //constructors and moifiers //accessors methods //toString public String toString() { return FACES[face] + " of " + suit; } This is a simple Card class. Card is extended to make specific types of cards. getValue( ) is implemented in each specific card.

© A+ Computer Science - public class Card { private String face; private String suit; private int value; //constructors and methods //not shown public String toString() { return face + “ “ + suit + “ “ + value; } There are many ways to build a card class. The Card and other classes from Elevens will not be directly tested. Classes and Lists of Classes will be tested.

© A+ Computer Science -

public class Deck { private List cards; public Deck() { cards = new ArrayList (); //use loops to add new Cards //to the List of Cards } You must spend considerable time working with Lists of Classes / References.

© A+ Computer Science -

public void shuffle() { // implement a // shuffle method // go online and research // shuffle methods }

© A+ Computer Science -

Card games require Card classes and a Deck of Cards. Most Card games require Player classes to created. Often, you need a List in order to simulate a real game. Creating a Card game with List and List is great prep for the AP CS A Exam.

© A+ Computer Science - Any game that uses Cards and Deck of Cards is a perfectly good substitute for the Elevens project. Blackjack – 21 is a great project as it has Cards, a Deck, Players, and a Dealer. Multi- player 21 is a very fun project.

© A+ Computer Science is a great card game that has relatively simple logic. Objects needed : Card, Deck, Player, Dealer, Game Deck - List of Cards People - List of Players

© A+ Computer Science -