cop2800 computer programming using java n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
COP2800 – Computer Programming Using JAVA PowerPoint Presentation
Download Presentation
COP2800 – Computer Programming Using JAVA

Loading in 2 Seconds...

play fullscreen
1 / 17

COP2800 – Computer Programming Using JAVA - PowerPoint PPT Presentation


  • 120 Views
  • Uploaded on

COP2800 – Computer Programming Using JAVA. University of Florida Department of CISE Spring 2013 Lecture 24 – Java Lists and Queues Webpage : www.cise.ufl.edu/~mssz/JavaNM/Top-Level.html. COP2800 – Programming in JAVA. Course Objectives Basic Knowledge of Computers & Programming

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'COP2800 – Computer Programming Using JAVA' - isaiah-myers


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
cop2800 computer programming using java

COP2800 – Computer Programming Using JAVA

University of Florida Department of CISE Spring 2013

Lecture 24 – Java Lists and Queues

Webpage:www.cise.ufl.edu/~mssz/JavaNM/Top-Level.html

cop2800 programming in java
COP2800 – Programming in JAVA
  • Course Objectives
    • Basic Knowledge of Computers & Programming
    • Specific Knowledge of JAVA Programming
    • Practical Programming Projects Build Skills
  • Today’s Class
    • Review of Collections
    • Lists and Queues
      • ArrayList and LinkedList
      • Specialization for Assignment-4
review java program structure
Review: Java Program Structure
  • JAVA Units:
  • Packages
  • Classes
  • (Instances)
  • Methods
  • Instructions
  • Variables

HIGH-LEVEL VIEW

PICTURE CREDIT: http://www.webbasedprogramming.com/JAVA-Developers-Guide/ch4.htm

review java package structure
Review: Java Package Structure

PICTURE CREDIT: http://users.soe.ucsc.edu/~charlie/book/notes/summary1-4/sld016.htm

review inheritance
Review: Inheritance

Example:

SUBCLASS #1 GOLFER

SUBCLASS #2 STUDENT

SUBCLASS #nELECTRICIAN

SUPERCLASS PERSON

Subclass

Variables:

swing

stance

grip

score

extends

Subclass

Variables:

gpa

health_status

major

extracurriculars

extends

Subclass

Variables:

availability

hourly_rate

company

unionized

extends

ADD

NEW

PROP-ERTIES

. . .

. . .

review polymorphism
Review: Polymorphism

NEW WORD: Overloading

Example:

int+int integer addition

int+float decimal addition

string +string concatenation

We say the “+” operator is overloaded

because one operator performs many functions

polymorphism cont d
Polymorphism (cont’d)

JAVA: One function to act on many objects

Example: length() method

Class #1 object1 = <value>

Class #2 object2 = <value>

object.length()

object.length()

new concept collections
New Concept: Collections

JAVA: Collection is a typed grouping of objects.

Example:

Suppose we have a Collection <Type> c

where <Type> denotes a datatype

We write according to this pattern:

List <Type> list = new

ArrayList<Type>(c);

collections cont d
Collections (cont’d)

Code

Example

OUTPUT:

Collection Example!

Collection data: Blue White Green Yellow

Collection size: 4

Code Example: http://www.tutorialspoint.com/javaexamples/collection_size.htm

new concept lists
New Concept: Lists

JAVA: ArrayList and LinkedList.

ArrayList: (expandable)

Like a vector or array but faster…

public ArrayList<type>

extendsAbstractList<type>

LinkedList:(expandable, can be traversed)

public ArrayList<type>

extendsAbstractSequentialList<type>

example array list
Example: Array List

Pre-existing Java Classes that must be imported

If I/O Error on InputStreamReader

Polymorphic “add” operation:

<class>.add(<arg>)

Code Credit: http://www.anyexample.com/programming/java/java_arraylist_example.xml

example array list cont d
Example: Array List (cont’d)

Error Handler

Read Name and calc. its Length

Reference array element by index

Code Credit: http://www.anyexample.com/programming/java/java_arraylist_example.xml

review linked list
Review: Linked List

Image Credit: http://www.mycstutorials.com/articles/data_structures/linkedlists

example linked list

Java Packages and Predefined Java Classes that must be imported

Example: Linked List

Define Constructor for Method

Polymorphic add

Code Credit: http://alvinalexander.com/blog/post/java/java-linkedlist-example-code

example linked list cont d
Example: Linked List (cont’d)

Cycle thru List (in order of insertion)

Output Strings Stored in List (in-order)

Polymorphic add

Code Credit: http://www.anyexample.com/programming/java/java_arraylist_example.xml

how we will use lists
How We will Use Lists
  • Assignment 4:
  • Add “Intelligence” to TicTacToe Game
    • Defensive Move(s): Block Opponent
      • Insert Your Symbol (X,O) into a Row/Col that
        • has been marked with an opponent’s symbol
      • Keep a History List of Moves (Knowledge Base)
    • Offensive Move(s): Complete Row/Col/Diag
      • Your opponent misses an opportunity to block
      • You can add more of your symbols to R/C/Diag
looking ahead
Looking Ahead …
  • Friday 15 Mar 2013:
  • How to do Assignment #4, Part II
    • Defensive Strategy
  • Discuss Assignment #4, Part III
      • Offensive Strategy (MORE CHALLENGING)
  • Monday 18 Mar 2013:
  • More Concepts (Analysis of Algorithms)
  • How to Apply Analysis to Assignment #4, Part IV