CS12230 Introduction to Programming Tying things together.

Slides:



Advertisements
Similar presentations
Cybercat Tutorial. This is the basic search screen in Cybercat. By clicking on the arrow you can specify the type of search you want to do.
Advertisements

MiniDraw Testing COMP 102 # T1
CHAPTER 10 FUN AND GAMES Group 1: Xiangling Liu.
PLANNING THE TIC TAC TOE GAME BY NEEL DAVE. TIC TAC TOE INSTRUCTIONS Tic Tac Toe Instructions The basic concept of Tic Tac Toe 1.This is a game for two.
12 Pontoon1May Pontoon program CE : Fundamental Programming Techniques.
Hand Crafting your own program By Eric Davis for CS103.
Representing a Game Board In a game, we represent the action taking place using an array – In a very simple game, we use individual variables to represent.
Design Example. Requirements Make a program that simulates the game of blackjack For now, we ignore money/betting…. just simulate game play But… this.
Notes on how to read a paper Reading is more than just passing your eyes over the words in consecutive order. Reading is understanding.
BINGO! Topic Create Your Game Card You will need a blank piece of paper.
CS 206 Introduction to Computer Science II 10 / 14 / 2009 Instructor: Michael Eckmann.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
CS 106 Introduction to Computer Science I 03 / 03 / 2008 Instructor: Michael Eckmann.
Online Chess Project 3 Due date: April 17 th. Introduction Third in series of three projects This project focuses on adding online support –2 players.
By Jennifer Adams. The traditional approach (or algorithm) for large number division is the most abstract and difficult approach to division. Yet many.
Bug Session One. Session description In this session, pupils are introduced to a programming sequence which will make a light pattern on their Bug. Objectives.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
HANGMAN Created By: Will Matthau & Christian Stumpf.
CS161 Topic #15 1 Today in CS161 Lecture #15 Practicing! Writing Programs to Practice Write a game program (1 player) of Mad Math Reuse the functions to.
General Programming Introduction to Computing Science and Programming I.
Iteration. Adding CDs to Vic Stack In many of the programs you write, you would like to have a CD on the stack before the program runs. To do this, you.
11 Finding Winners Using Arrays Session 8.2. Session Overview  Find out how the C# language makes it easy to create an array that contains multiple values.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Passing Other Objects Strings are called immutable which means that once a String object stores a value, it never changes –recall when we passed a message.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
JCT Curriculum Night How to Help Your Child with Reading at Home.
CS12420 Sequence Diagrams – a UML notation for modelling bahaviour Lynda Thomas Images from Wikipedia unless credited or mine.
By the end of this session you should be able to...
CSE 143 Lecture 17 More Recursive Backtracking reading: "Appendix R" on course web site slides created by Marty Stepp and Hélène Martin
CSE 143 Lecture 17 More Recursive Backtracking reading: "Appendix R" on course web site slides created by Marty Stepp and Hélène Martin
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
Tree Diagrams  Be able to use a tree diagram to list the possible outcomes from two events.  Be able to calculate probabilities from tree diagrams. 
CS 106 Introduction to Computer Science I 01 / 31 / 2007 Instructor: Michael Eckmann.
Making Decisions uCode: October Review What are the differences between: o BlueJ o Java Computer objects represent some thing or idea in the real.
Code reading skills LEVEL GAME.  Skeleton has error messages.  Notice the red lines on right slider. Click… you’ll go to an error.  pieces = levels.getPieces();
CS 206 Introduction to Computer Science II 02 / 23 / 2009 Instructor: Michael Eckmann.
COP Structures Instructor: Diego Rivera-Gutierrez I’m back baby!
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
1 Project Management Example Solving Sudoku 2 What is Sudoku?  Sudoku is a game with 9 columns and 9 rows and 9 “boxes” composed of a 3 x 3 Grid  Numbers.
CHAPTER 1 – INTRODUCTION TO ACCESS Aliya Farheen March 5, 2014.
Multiplying Decimals Type your name and send: Next slide.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
CS 106 Introduction to Computer Science I 03 / 02 / 2007 Instructor: Michael Eckmann.
Algorithms CS280 – 10/20/05. Announcement  Part 1 of project 2 due.  Read chapters 10, 7 for this unit  Tuesday we will also be in the classroom We.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
CSE 143 Lecture 18 More Recursive Backtracking slides created by Marty Stepp
CS Class 15 Today  More practice with arrays  Introduction to Multi-dimensional arrays Announcements  Programming project #4 due 10/23 by midnight.
Problem Decomposition and Abstraction. Problem Solving Which one is easier:  Solving one big problem, or  Solving a number of small problems?
An Introduction to Programming and Object Oriented Design using Java 2 nd Edition. May 2004 Jaime Niño Frederick Hosch Chapter 8: Putting a System Together.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
How do I multiply a triple digit number by a double digit? 145 x 67 = ? 267 x 19 = ? I’m sure that you’ll agree that there are many methods that we can.
CS12230 Introduction to Programming Extra example– More on responsibilities 1.
Theme What theme will you base your game on? Could be: sports, books, movies, United States, Presidents, animals, or anything in the world. Make sure.
THE CAVE OF MAGIC Enter IF YOU DARE!!!. Warning!! Be careful and stuff. Things will happen to you. Try to win. You may lose. You must know how to read.
Fractions, Decimals, and Percents Today’s Learning Goals We will review the link between fractions, decimals, and percents by playing the Four in a Row.
Shlomo Hershkop Basics overview. Shlomo Hershkop Basic Review - Overview Practice coding Practice coding finger guessing game finger guessing.
© 2016 AQA. Created by Teachit for AQA Lesson Representing algorithms (decomposition)
Year 5 - Numeracy Title page..
CS 106A, Lecture 3 Problem-solving with Karel
C ++ Pointer code.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Computer Science Testing.
Truth tables: Ways to organize results of Boolean expressions.
Flowcharts and Pseudo Code
LONG MULTIPLICATION is just multiplying two numbers.
Tree Diagrams Be able to use a tree diagram to list the possible outcomes from two events. Be able to calculate probabilities from tree diagrams. Understand.
Presentation transcript:

CS12230 Introduction to Programming Tying things together

What do you do when faced with a blank page? A ‘methodology’ is a way of working that you can follow Simple methodology …

START PROGRAM Design PhaseImplementation Phase Test with diagrams and on paper against USE CASES to see if it should work Figure out basic classes And algorithms OBJECT AND CLASS DIAGS and PSEUDOCODE Define problem USE CASE Code into program Test against USE CASEs To see if it does all it should Requirements Phase

Understand the problem. Try sketching out how you would solve it without a computer What are the objects and classes in the problem? What information do you have about them – attributes? What do they do (their responsibilities) – methods? Code a couple of classes – even simple stuff will get you started. When stuck put in a comment like //this is where I sort things - don’t know how yet Think about the main application again – how can you use your classes? Test out your idea by running through an example.

Use-case diagram Final question is – will your system be able to do all these things?

Object Diagram - Library

Class Diagram Book - String title -String author -String isbn -Person checkedOutTo +Book(String t, String a, String code) +checkout(Person p); Library - Person[] customers -Book[] books Person - String name -Book[] booksOut +Person (String n) +addBook(Book b) 0..* 0..1

Now the trickiest part –can you trace through the use cases to see that your system can do them? :Person :Book :Library List of Books List of Person

Pseudocode – then code To check out a book (you know the person’s name and the book’s call number): Find theCustomer in customer list using name Find theBook in book list using call number theCustomer.addBook(theBook) theBook.setCheckedOutTo(theCustomer) } If you don’t have these methods then you must add them

Turning to java is relatively easy! public class Book{ private String isbn; private Person checkedOutTo; //etc void setCheckedOutTo(Person p) { checkedOutTo = p; } //etc } public class Person{ private String name; private ArrayList booksOut; //etc void addBook(Book b) { booksOut.add(b); } //etc } public class Library{ private ArrayList customers; private ArrayList books; void checkout(String custName, String isbn) { … }

EXAMPLE – HERE IS USE-CASE Think about a X and O game -play game()

Classes: Game, Board, Player What do they ‘have’? Game has 2 players and a Board Player has a symbol and a link to theBoard Board has a 3x3 grid of characters What do they obviously ‘do’? Game plays the game > Player takes a turn by placing a piece Board displays

Player -String name -char symbol -Board board +takeTurn() Board -char grid[3][3] + toString() + ????? Game - Player p1,p2 -Board board +play()

How do we play the game then? (this was the only use case) While (not 9 moves) { player1.takeTurn() if (board.winner()) break; player2.takeTurn() if (board.winner()) break; } this method in Player this one in Board

Investigate takeTurn() further Let them enter a row and column If (board.valueAt(row,col)==‘ ‘) board.newMove(row, col, symbol) So need these 2 methods in Board

So, 3 new methods of Board to investigate winner(): 3 ways of winning (tedious and tricky so might code each with a private method) valueAt() newMove() Also, toString() to display

End up with: Actually could be private?

Notice how responsibilities are passed around