Interfaces: JAVA CONTRACTS
|
|
- Barnaby Richardson
- 5 years ago
- Views:
Transcription
1 Interfaces: JAVA CONTRACTS
2 Homework Stamp #3: Udacity Problem Set #6, # Quiz Question #2
3 Warm-Up
4 SuperFriends Video Game! You ve been hired to work on the brand-new Super Friends video game!
5 Mrs. Fronk wrote a SuperMan Class Her job was to create properties and behaviors that Superman would possess.
6 Mrs. D wrote a WonderWoman Class It has methods and instance variables that describe Wonder Woman.
7 Your Job: Class defeatprometheus You re in charge of a class that plays out a battle with the villain, Prometheus. Superman and Wonder Woman are both characters that players might use in this scene.
8 Fly!!! A big part of the battle involves the characters flying around Prometheus and attacking him. Superman flies by jumping into the air Wonder Woman uses a cool invisible plane to fly
9 You carve out time at 1AM to code You can t see Mrs. Fronk s code, or Mrs. Donaldson s code, but you know that you can instantiate a Superman Object and a WonderWoman Object using the default constructor Superman clarkkent = new Superman(); WonderWoman Diana = new WonderWoman() Now you re ready to make clarkkend and Diana fight Prometheus!
10 You start with Superman You try to make him fly by trying to guess the name of Mrs. Fronk's flying method : clarkkent.fly(); clarkkent.takeoff(); clarkkent.soar();.but nothing works :(
11 You have to CALL Mrs. F at 2:00 AM to ask what she named the method Oh! Sorry! It s called: itsabird() Now you know: clarkkent.itsabird();
12 Now you try the same thing for Wonder Woman WonderWoman Diana = new WonderWoman(); Diana.Fly(); Diana.ItsAPlane(); Diana.Invisible(); Nothing Works
13 Now you have to call Mrs. D Oh Sorry! It s invisiblejet() Now you can code! Clark.itsABird(); Diana.invisibleJet(); But that took WAY too long. Surely there s a better way...
14 Syntax : INTERFACE An INTERFACE is like a CONTRACT among programmers It s an agreed-upon list of methods and properties that a team uses when they re working on the same project. It establishes common names so that cooperation is easy.
15 Interface SuperHero public Interface Superhero { } public void fly(); public int gethealth(); //what are some other handy methods?? These are ABSTRACT methods, just suggestions. Each class that implements this interface must make them CONCRETE, or fully coded.
16 Syntax: implement A class implements an interface: class Superman implements Superhero //That means we know this class has a method called fly public void fly() { out.println ( I m a bird! I m a plane! I m Superman! ); }
17 WonderWoman and Batman, too: //Class Wonderwoman public void fly() { out.println ( Into the jet! ); } //Class Batman public void fly() { out.println ( My cape is out! ); }
18 Here s the cool part!!! If I add IMPLEMENT different classes with the SAME interface public class WonderWoman implements Superhero public class SuperMan implements Superhero public class Batman implements Superhero
19 THEN I can INSTANTIATE THEM ALL AS THE SAME TYPE OF INTERFACE Superhero diana = new WonderWoman(); Superhero clarkkent = new Superman(); Superhero brucewayne = new Batman();
20 And then I can put them in THE SAME array even though they are of different types! Superhero[] superfriends = new Superhero[3]; superfriends[0] = diana; superfriends[1] = clarkkent; superfriends[2] = brucewayne;
21 I can even skip the naming part and instantiate new Superheros like this Superhero[] superfriends = new Superhero[3]; superfriends[0] = new Superman(); superfriends[1] = new WonderWoman(); superfriends[2] = new Batman();
22 I can make them all fly because it s in the interface. The array will call each type s individual fly() method. Code SuperFriends[0].fly() SuperFriends[1].fly() Output It s a bird! It s a plane! It s Superman! Into the jet!
23 They can also call their GetHealth methods Code SuperFriends[1].getHealth() Output Wonder Woman is healthy and strong at 9/10 SuperFriends[2].getHealth() Batman is about to crash at 1/10!!!
24 Interfaces are a huge part of POLYMORPHISM Polymorphism s goal is to have the same method name work for many different types. It makes different types ACT alike.
25 AP TRICK!!!!! YOU CANNOT instantiate an interface NO: Superhero Diana = new Superhero(); //This means Diana only has abstract methods YES: Superhero Diana = new WonderWoman(); //This means Diana has her own Wonderful Way of performing the abstract methods in SuperHero The Interface on the right, Class Type on the left
26 Facts about interfaces - COPY 1) All methods in an interface must be abstract 2) All variables must be public static final (constant) 3) Interfaces cannot be instantiated 4) Interfaces cannot contain constructor methods 5) Interfaces are abstract classes - just ideas of what should happen 6) Classes may implement more than one interface
27 HOMEWORK 1) Do Interface Worksheet #1
28 Coding Bat: This one is tricky!
29 Warm-Up Let s Practice! You bought a zoo! Practice interfaces Learn about how.equals works
30 Grade FRQ - put in your log
31 Interface Comparable, Most Common public interface Comparable { int compareto(object obj) } //Any class that implements Comparable must include a method that compares objects of that class.
32 Why do we need comparable? It s important so that JAVA has a way to sort Objects. It s like equals
33 Sort Example Last week we talked about Monsters. Let s say that each Monster has 3 properties (instance variables) Name Height age Elmo 32 6 Cookie 48 4 Sully
34 Sort Example Monster[ ] monsters = new Monster[3]; monsters[0] = new Monster( Elmo, 32, 6); monsters[1] = new Monster( Cookie, 48, 4); monsters[2] = new Monster( Sully, 721, 38); monsters Elmo 32 6 Cookie 48 4 Sully
35 I want to sort the Monsters, but can t Arrays.sort(monsters); //this returns an error! What s the problem? monsters Elmo 32 6 Cookie 48 4 Sully
36 JAVA doesn t know how we want to sort Do we want to sort alphabetically by name? Or in increasing order by weight? Or in decreasing order by weight? Or sort by age? ACK! monsters Elmo 32 6 Cookie 48 4 Sully
37 We need to select our own sort critiera: Let s pick increasing order by age. Lower ages come before higher ages Let s write the code. monsters Elmo 32 6 Cookie 48 4 Sully
38 public int compareto(object o) { public int compareto(object obj) { Monster other = (Monster) obj; int difference = this.getage() -other.getage(); return difference; } monsters Elmo 32 6 Cookie 48 4 Sully
39 COPY Syntax - words in red ALWAYS THE SAME public int compareto(object obj) { Monster other = (Monster) obj; //cast to the type you re comparing int difference = this.getage() -other.getage(); //get the variable to compare return difference; } monsters Elmo 32 6 Cookie 48 4 Sully
40 Now one monster can compare himself to another! What would be output if Elmo is 6 and Cookie is 4 and Sully is 721? Elmo.compareTo(Cookie); Elmo.compareTo(Sully);
41 Even better to use the array monsters //What would be output? mosters[0].compareto(monsters[1]); mosters[0].compareto(monsters[1]); monsters Elmo 32 6 Cookie 48 4 Sully
42 NOW Collections.sort(monsters will work) Because the sort() method will know how to compare one monster to the other. If compareto() returns a positive number, sort will switch the elements. 6-4 = 2, so Elmo and Cookie will switch. monsters Elmo 32 6 Cookie 48 4 Sully
43 Is superman healthier than Wonder Woman? public int compareto(object obj) //Finds the difference in health points of 2 superheroes { Superhero other = (Superhero) obj; int difference = this.gethealth() - other.gethealth(); return difference; } //Runner. If Superman s health is 4 and WW s is 7, what would be returned? Clark.compareTo(Diana);
44 math Example of Interface: You write an interface when you know WHAT you want to be done without knowing HOW. public interface Circles { public abstract int findcircumference(object obj); //abstract implied, the word is optional private static final int pi = ; //variables must be private static final }
45 Combining Interfaces / public interface Locatable { public int getx(); public int gety(); } public interface Moveable { public void setpos(int x, int y); public void setx(int x); public void sety(int y); }
46 We can use them both! class Ship implements Locatable, Moveable { private int xpos, YPos; //How many methods have to be written? }
47 Fast Facts: Syntax All methods in an interface must be public abstract. All variables in an interface must be public static final An interface cannot be instantiated Interfaces cannot contain implemented (written)methods Interfaces are considered to be purely abstract classes
48 Homework: Interface worksheet #2 Class Complete Worksheet #9
49 Tomorrow! Multiple Choice test - 20 Questions on: Arrays of References Lists of References Study worksheets with those names ^^
50 Warm-Up: Defaults TYPE DEFAULT int double boolean String Object
51 Warm-Up: Defaults TYPE DEFAULT int 0 double 0.0 boolean String Object (any Object) false null null
52 Add a new Monster to monsterarray at 1 with age 5, weight 50, and name Boo public Monster (int a, int w, String n); {This is the constructor)
53 Add a new Monster to MonsterArray at 1 with age 5, weight 50, and name Boo Grover public Monster (int a, int w, String n); {This is the constructor) monsterarray[1] = new Monster(5, 50, Boo );
54 Add a new Monster to MonsterList with age 5, weight 50, and name Boo public Monster (int a, int w, String n); {This is the constructor)
55 Add a new Monster to MonsterArray with age 5, weight 50, and name Boo Grover public Monster (int a, int w, String n); {This is the constructor) monsterlist.add (new Monster(5, 50, Boo ));
56
57 Print the Weight of all the Monsters in monsterlist; Use a for-each
58 Print the Weight of all the Monsters For (Monster m:monsterlist) out.println(m.getweight());
59 TEST! 20MC Arrays/Lists of Objects
60 Lab Today Labs 19 Interfaces set 1 interfaces Interfaces Monster Lab 1 *Code In Canvas
61 Homework: Udacity PS 9, #1-8
62 Valentine Kahoot!
63 Warm-Up: Interface Kahoot! Interface 1 Interface 2
64 FRQ: Interfaces Do and turn in
65 Homework: Practice IT ODD ONLY
66 Homework 1) FRQ part b 2) MUST: Udacity Lesson #9 # ) RECOMMENDED FOR SERIOUS CODERS: #9-14 (Casting and checking for interfaces)
67 Warm Up! ax + by + c = 0, slope = -a/b 4x + 3y - 12 = 0 a) What is the slope of this line? b) Is the point (2,1) on this line?
68 Classwork : In Groups Answers on a piece of binder paper to turn in. 1) White multiple choice questions 2) 2010 FRQs, pink, #1 & 2
69 #1 answers a) int boxes = 0; for (CookieOrder o : orders) boxes += o.getnumboxes(); return boxes; } b) int boxesremoved = 0; for (int i = orders.size() - 1; i >= 0; i--) { if (orders.get(i).getvariety().equals(cookievar)) boxesremoved += orders.remove(i).getnumboxes(); ** } return boxesremoved; } **Could be 2 steps: boxesremoved += orders.get(i).getnumboxes(); orders.remove(i);
70 #2 public class APLine { private int a, b, c; public APLine(int a1, int b1, int c1) { a = a1; b = b1; c = c1; } public double getslope() { return -(a / ((double) b)); } public boolean isonline(int x, int y) { return a * x + b * y + c == 0; } }
71 #3 a) public boolean isleveltrailsegment(int start, int end) { int minelevation = markers[start]; int maxelevation = markers[start]; for (int i = start + 1; i <= end; i++) { if (markers[i] < minelevation) minelevation = markers[i]; if (markers[i] > maxelevation) maxelevation = markers[i]; } b) public boolean isdifficult() { int significantchanges = 0; for (int i = 1; i < markers.length; i++) if (Math.abs(markers[i - 1] - markers[i]) >= 30) significantchanges++; return significantchanges >= 3; } return maxelevation - minelevation <= 10; }
72 Homework!!! FRQ 2014 #1 part b
AP Computer Science Homework Set 2 Class Design
AP Computer Science Homework Set 2 Class Design P2A. Write a class Song that stores information about a song. Class Song should include: a) At least three instance variables that represent characteristics
More informationITP 165: Introduction to C++ Programming Homework 10: Superhero fight Due: 11:59pm, December 1 st, 2017
ITP 165: Introduction to C++ Programming Homework 10: Superhero fight Due: 11:59pm, December 1 st, 2017 Goal Finishing the functionality introduced in Homework 9, you ll implement fights that can occur
More informationA+ Computer Science. strings
A+ Computer Science strings Agenda 1) 2) 3) 4) Warm-UP Coding Bat Stamp Hw: Practice IT 2.1 to 2.19 odd, no 2.5 Lecture: Strings October worksheet #1 - Strings! Warm-Up: Strings are WORDS String s = "apluscs";
More informationTaxiBot New attributes Variables Math! TaxiBot
TaxiBot New attributes Variables Math! TaxiBot TaxiBot operates in the city BUT it charges you for its actions TaxiBot extends RobotSE TaxiBot displays how much is owed 1 TaxiBot charges Moving 1 space
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Interface Abstract data types Version of January 26, 2013 Abstract These lecture notes are meant
More informationLesson 2.4 Arraylist
Lesson 24 Arraylist Mimi Duong Rosalba Rodriguez Java Crash Course January 6th, 2015 Data Structure ArrayLists Live Coding Methods Searching Through ArrayLists Classwork Storing Items in Java How have
More informationCMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.
CMSC131 Inheritance Object When we talked about Object, I mentioned that all Java classes are "built" on top of that. This came up when talking about the Java standard equals operator: boolean equals(object
More informationUnit 9 Tech savvy? Tech support. 1 I have no idea why... Lesson A. A Unscramble the questions. Do you know which battery I should buy?
Unit 9 Tech savvy? Lesson A Tech support 1 I have no idea why... A Unscramble the questions. 1. which battery / Do you know / should / buy / I? Do you know which battery I should buy? 2. they / where /
More informationCS/ENGRD 2110 SPRING Lecture 7: Interfaces and Abstract Classes
CS/ENGRD 2110 SPRING 2019 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due Thursday night (14 February) Go back to Lecture 6 & discuss method
More informationA+ Computer Science MATRICES
A+ Computer Science MATRICES Warm Up: Scores Clump Coding Bat Today: The Matrix 2Day Arrays - Matrices A two-dimensional array is a one-dimensional array of one-dimensional arrays. A spreadsheet is an
More informationSession 4 Starting the Air Raid Game
Session 4 Starting the Air Raid Game Authored by Brian Cullen (bcullen@rossettschool.co.uk/@mrbcullen) (c) Copyright 2011 Computing At School. This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike
More informationWe will stamp HW Block day:
Sorting Videos! We will stamp HW Block day: #10 Recursion worksheet #3 #11 12 Recursion-1 Coding Bats #12 Code Step By Step (see canvas) Today we Dance! No Homework tonight :) Guest Speaker Masters in
More informationMIT AITI Lecture 18 Collections - Part 1
MIT AITI 2004 - Lecture 18 Collections - Part 1 Collections API The package java.util is often called the "Collections API" Extremely useful classes that you must understand to be a competent Java programmer
More informationJava Classes, Inheritance, and Interfaces
Java Classes, Inheritance, and Interfaces Introduction Classes are a foundational element in Java. Everything in Java is contained in a class. Classes are used to create Objects which contain the functionality
More informationAP Computer Science in Java Course Syllabus
CodeHS AP Computer Science in Java Course Syllabus College Board Curriculum Requirements The CodeHS AP Java course is fully College Board aligned and covers all seven curriculum requirements extensively
More informationA+ Computer Science MATH / OOP. A+ Computer Science -
A+ Computer Science MATH / OOP Warm-Up! Quiz Review Worksheet Calculations Expressions average = total / 5 sum = one + two Expressions usually consist of operators, variables, and/or values. Operators
More informationCreating Java Programs with Greenfoot
Creating Java Programs with Greenfoot Working with Source Code and Documentation 1 Copyright 2012, Oracle and/or its affiliates. All rights Objectives This lesson covers the following topics: Demonstrate
More informationPolymorphism and Interfaces. Corky Cartwright Department of Computer Science Rice University
Polymorphism and Interfaces Corky Cartwright Department of Computer Science Rice University 1 Polymorphism In Scheme, we defined a multitude a different kinds of lists: list-of-numbers, list-of-symbols,
More informationJAVA MOCK TEST JAVA MOCK TEST II
http://www.tutorialspoint.com JAVA MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your
More informationCS 170 Java Programming 1. Week 12: Creating Your Own Types
CS 170 Java Programming 1 Week 12: Creating Your Own Types What s the Plan? Topic 1: A Little Review Work with loops to process arrays Write functions to process 2D Arrays in various ways Topic 2: Creating
More informationInterlude. 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 informationSTUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes
STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes Java Curriculum for AP Computer Science, Student Lesson A20 1 STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes INTRODUCTION:
More informationComparing Objects 3/28/16
Comparing Objects 3/28/16 Agenda HW Notes Practice Tests Returned Searching Data One of the most important and useful things that computers do is search through huge amounts of data. Search Engines Patterns
More informationLesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class
More informationIntroduction to Security
CS 166: Information Security Introduction to Security Prof. Tom Austin San José State University Why should we learn about information security? Computer Security in the News Computer Crime for Fun & Profit
More informationAbstract classes are used to define a class that will be used only to build new classes. No objects will ever be instantiated from an abstract class.
Abstract classes are used to define a class that will be used only to build new classes. No objects will ever be instantiated from an abstract class. Mammal (abstract class) Human Whale Cow Any sub class
More informationComparing Objects 3/14/16
Comparing Objects 3/14/16 Agenda HW Notes Practice Tests Returned Searching Data One of the most important and useful things that computers do is search through huge amounts of data. Search Engines Patterns
More informationWhat did we talk about last time? Finished hunters and prey Class variables Constants Class constants Started Big Oh notation
Week 12 - Friday What did we talk about last time? Finished hunters and prey Class variables Constants Class constants Started Big Oh notation Here is some code that sorts an array in ascending order
More informationCS 61B Data Structures and Programming Methodology. July 2, 2008 David Sun
CS 61B Data Structures and Programming Methodology July 2, 2008 David Sun Announcements Project 1 spec and code is available on the course website. Due July 15 th. Start early! Midterm I is next Wed in
More informationSoftware Paradigms (Lesson 3) Object-Oriented Paradigm (2)
Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationWarm-up for Integrated Geometry and Algebra I
Summer Assignment Warm-up for Integrated Geometry and Algebra I Who should complete this packet? Students who will be taking Integrated Geometry and Algebra I in the fall of 018. Due Date: The first day
More informationRecommended Group Brainstorm (NO computers during this time)
Recommended Group Brainstorm (NO computers during this time) Good programmers think before they begin coding. Part I of this assignment involves brainstorming with a group of peers with no computers to
More informationFINAL EXAMINATION. COMP-250: Introduction to Computer Science - Fall 2010
STUDENT NAME: STUDENT ID: McGill University Faculty of Science School of Computer Science FINAL EXAMINATION COMP-250: Introduction to Computer Science - Fall 2010 December 20, 2010 2:00-5:00 Examiner:
More informationAP CS Unit 6: Inheritance Exercises
AP CS Unit 6: Inheritance Exercises 1. Suppose your program contains two classes: a Student class and a Female class. Which of the following is true? a) Making the Student class a subclass of the Female
More informationAnother interface: Comparable
Another interface: Comparable Comparing things is certainly useful, e.g. for sorting Show me cats ordered by cuteness" Show shapes ordered by number of sides" An example interface: Comparable Since sorting
More information} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.
Class #10: Understanding Primitives and Assignments Software Design I (CS 120): M. Allen, 19 Sep. 18 Java Arithmetic } Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = 2 + 5 / 2; 3.
More informationCS/ENGRD 2110 SPRING 2018
CS/ENGRD 2110 SPRING 2018 Lecture 7: Interfaces and http://courses.cs.cornell.edu/cs2110 1 2 St Valentine s Day! It's Valentines Day, and so fine! Good wishes to you I consign.* But since you're my students,
More informationOverview. ITI Introduction to Computing II. Interface 1. Problem 1. Problem 1: Array sorting. Problem 1: Array sorting. Problem 1: Array sorting
Overview ITI 1121. Introduction to Computing II Rafael Falcon and Marcel Turcotte (with contributions from R. Holte) Electrical Engineering and Computer Science University of Ottawa Interface Abstract
More informationSolutions to Quiz 1 (March 14, 2016)
MIT 6.005: Software Construction Max Goldman revised Wednesday 16 th March, 2016, 14:08 Solutions to Quiz 1 (March 14, 2016) Problem 1 (Multiple Choice) (20 points). (a) Which of the following must be
More informationGrade 6 Math Circles November 10, 2010 Algebra
1 University of Waterloo Faculty of Mathematics Centre for Education in Mathematics and Computing Grade 6 Math Circles November 10, 2010 Algebra Solving Equations (Addition & Subtraction) When we are given
More informationHomework Set 2- Class Design
1 Homework Set 2- Class Design By the end of the lesson students should be able to: a. Write the Java code define a class, its data members, and its constructors. b. Write a tostring() method for a class.
More informationCMSC132 Summer 2018 Midterm 1
CMSC132 Summer 2018 Midterm 1 First Name (PRINT): Last Name (PRINT): Instructions This exam is a closed-book and closed-notes exam. Total point value is 100 points. The exam is a 80 minutes exam. Please
More informationSpring, 2014 CIT 590. Programming Languages and Techniques Homework 7
Spring, 2014 CIT 590 Programming Languages and Techniques Homework 7 Mar 21, 2014; Due Mar 28, 2014, before first recitation This homework deals with the following topics * Getting started with Java *
More informationExpress Yourself. Writing Your Own Classes
Java Programming 1 Lecture 5 Defining Classes Creating your Own Classes Express Yourself Use OpenOffice Writer to create a new document Save the file as LastFirst_ic05 Replace LastFirst with your actual
More informationQuiz. Programming Languages. CSE 130 : Fall Lecture 16: Static Types for Objects. Ranjit Jhala UC San Diego
CSE 130 : Fall 2008 Programming Languages Quiz Lecture 16: Static ti Types for Objects Ranjit Jhala UC San Diego Last time Tricks with namespaces: decorators Today Inheritance Static Types for Objects
More informationLast Time. University of British Columbia CPSC 111, Intro to Computation Alan J. Hu. Readings
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Writing a Simple Java Program Intro to Variables Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch
More informationAdvanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II
Advanced Programming - JAVA Lecture 4 OOP Concepts in JAVA PART II Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Ad hoc-polymorphism Outline Method overloading Sub-type Polymorphism Method overriding Dynamic
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract
More informationCSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3:
PROGRAMMING ASSIGNMENT 3: Read Savitch: Chapter 7 Programming: You will have 5 files all should be located in a dir. named PA3: ShapeP3.java PointP3.java CircleP3.java RectangleP3.java TriangleP3.java
More informationAP CSA 3rd Period MR. D. Course Map
AP CSA 3rd Period MR. D. Course Map AP Computer Science in Java (Mocha) Aug. 10, Aug. 11, Aug. 14, Aug. 15, 1.1.1 Introduction to With Karel 1.1.2 Quiz: Karel Commands 1.1.3 Our First Karel Program 1.1.4
More informationQuiz 1 Unit 5A Arrays/Static Name
Quiz 1 Unit 5A Arrays/Static Name 1. What values are stored in arr after the following code segment has been executed? int[] arr = 1, 2, 3, 4, 5, 6, 7, 8; for (int k = 1; k
More informationAssignment 2 Due Thursday 7/3 at 10:00 AM
Assignment 2 Due Thursday 7/3 at 10:00 AM Working with Strings II (25 points): Download the file StringMaster2003.java from the course web page (the assignments page). You will find code which produces
More informationJava Classes & Primitive Types
Java Classes & Primitive Types Rui Moreira Classes Ponto (from figgeom) x : int = 0 y : int = 0 n Attributes q Characteristics/properties of classes q Primitive types (e.g., char, byte, int, float, etc.)
More informationCS/ENGRD 2110 FALL Lecture 7: Interfaces and Abstract Classes
CS/ENGRD 2110 FALL 2017 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 1 Announcements 2 A2 is due tomorrow night (17 February) Get started on A3 a method every other day.
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract
More information(1) Students will be able to explain basic architecture and components of digital computers and networks, and basic programming language features.
Content/Discipline Java Manhattan Center for Science and Math High School Mathematics Department Curriculum Marking Period 1 Topic and Essential Question JSS (1) What are computers? (2) What is hardware
More informationIntroduction to Computer Science Unit 4B. Programs: Classes and Objects
Introduction to Computer Science Unit 4B. Programs: Classes and Objects This section must be updated to work with repl.it 1. Copy the Box class and compile it. But you won t be able to run it because it
More informationCS106B Handout 26 Autumn 2012 October 29 th, 2012 Section Handout
CS106B Handout 26 Autumn 2012 October 29 th, 2012 Section Handout Discussion Problem 1: Planetarium Memory Trace Analyze the following program, starting with the call to littledipper, and draw the state
More informationIntroduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples
Introduction to Typed Racket The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Getting started Find a machine with DrRacket installed (e.g. the
More informationComputer Science 210: Data Structures
Computer Science 210: Data Structures Welcome to Data Structures! Data structures are fundamental building blocks of algorithms and programs Csci 210 is a study of data structures design efficiency implementation
More informationPage 1 CCM6 Unit 10 Graphing UNIT 10 COORDINATE PLANE. CCM Name: Math Teacher: Projected Test Date:
Page 1 CCM6 Unit 10 Graphing UNIT 10 COORDINATE PLANE CCM6 2016-17 Name: Math Teacher: Projected Test Date: Main Concept Page(s) Vocabulary 2 Coordinate Plane Introduction graph and label 3-6 Reflect across
More informationJava Classes & Primitive Types
Java Classes & Primitive Types Rui Moreira Classes Ponto (from figgeom) x : int = 0 y : int = 0 n Attributes q Characteristics/properties of classes q Primitive types (e.g., char, byte, int, float, etc.)
More informationCOE318 Lecture Notes Week 8 (Oct 24, 2011)
COE318 Software Systems Lecture Notes: Week 8 1 of 17 COE318 Lecture Notes Week 8 (Oct 24, 2011) Topics == vs..equals(...): A first look Casting Inheritance, interfaces, etc Introduction to Juni (unit
More informationCOP 3330 Final Exam Review
COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time
More informationCS 3 Midterm 1 Review
CS 3 Midterm 1 Review 1. Quick Evaluations Indicate what each of the following would return if typed into STK. If you think it would error, then please write ERROR. If you think that it would loop forever,
More informationUnit 2: Functions, Equations, & Graphs of Degree One
Date Period Unit 2: Functions, Equations, & Graphs of Degree One Day Topic 1 Relations and Functions Domain and Range 2 Graphing Linear Equations Objective 1 3 Writing Equations of Lines 4 Using the Graphing
More informationCS 170 Java Programming 1. Week 13: Classes, Testing, Debugging
CS 170 Java Programming 1 Week 13: Classes, Testing, Debugging What s the Plan? Short lecture for makeup exams Topic 1: A Little Review How to create your own user-defined classes Defining instance variables,
More informationUniversity of Utah School of Computing
University of Utah School of Computing CS 1410 / CS 2000 Study Notes December 10, 2011 This study guide is designed to help you prepare and study the appropriate material for the final exam. For the multiple
More informationObject-Oriented Design Lecture 23 CS 3500 Fall 2009 (Pucella) Tuesday, Dec 8, 2009
Object-Oriented Design Lecture 23 CS 3500 Fall 2009 (Pucella) Tuesday, Dec 8, 2009 23 Odds and Ends In this lecture, I want to touch on a few topics that we did not have time to cover. 23.1 Factory Methods
More informationLast time s big ideas
Last time s big ideas 1. When we want an array of objects, we store their references in the array 2. It is important to distinguish between the specification and implementation of a class 3. public and
More informationExploring Change and Representations of Change: Calculus Concept Connection i
Exploring Change and Representations of Change: Calculus Concept Connection i Grade Level and Content: Pre-algebra, 7 th or 8 th Grade Mathematics Big Idea: Students explore the concept of change and how
More informationCMSC132 Summer 2018 Midterm 1. Solution
CMSC132 Summer 2018 Midterm 1 Solution First Name (PRINT): Last Name (PRINT): Instructions This exam is a closed-book and closed-notes exam. Total point value is 100 points. The exam is a 80 minutes exam.
More informationCS 170 Java Programming 1. Week 15: Interfaces and Exceptions
CS 170 Java Programming 1 Week 15: Interfaces and Exceptions Your "IC" or "Lab" Document Use Word or OpenOffice to create a new document Save the file as IC15.doc (Office 97-2003 compatible) Place on your
More informationProgramming 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 informationPage 1 CCM6+ Unit 10 Graphing UNIT 10 COORDINATE PLANE. CCM Name: Math Teacher: Projected Test Date:
Page 1 CCM6+ Unit 10 Graphing UNIT 10 COORDINATE PLANE CCM6+ 2015-16 Name: Math Teacher: Projected Test Date: Main Concept Page(s) Vocabulary 2 Coordinate Plane Introduction graph and 3-6 label Reflect
More informationCSCI 1301: Introduction to Computing and Programming Spring 2019 Lab 10 Classes and Methods
Note: No Brainstorm this week. This lab gives fairly detailed instructions on how to complete the assignment. The purpose is to get more practice with OOP. Introduction This lab introduces you to additional
More informationCS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 1: Overview http://courses.cs.cornell.edu/cs2110 1 Course Staff Instructor Thorsten Joachims (tj@cs.cornell.edu)
More informationTopic 7: Inheritance. Reading: JBD Sections CMPS 12A Winter 2009 UCSC
Topic 7: Inheritance Reading: JBD Sections 7.1-7.6 1 A Quick Review of Objects and Classes! An object is an abstraction that models some thing or process! Examples of objects:! Students, Teachers, Classes,
More informationCS250 Intro to CS II. Spring CS250 - Intro to CS II 1
CS250 Intro to CS II Spring 2017 CS250 - Intro to CS II 1 Topics Virtual Functions Pure Virtual Functions Abstract Classes Concrete Classes Binding Time, Static Binding, Dynamic Binding Overriding vs Redefining
More informationAbstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.
a and Interfaces Class Shape Hierarchy Consider the following class hierarchy Shape Circle Square Problem AND Requirements Suppose that in order to exploit polymorphism, we specify that 2-D objects must
More informationCS/ENGRD 2110 FALL Lecture 7: Interfaces and Abstract Classes
1 CS/ENGRD 2110 FALL 2016 Lecture 7: Interfaces and Abstract Classes http://courses.cs.cornell.edu/cs2110 Announcements 2 Attendance for this week s recitation is mandatory! A2 is due Today Get started
More informationAn introduction to Java II
An introduction to Java II Bruce Eckel, Thinking in Java, 4th edition, PrenticeHall, New Jersey, cf. http://mindview.net/books/tij4 jvo@ualg.pt José Valente de Oliveira 4-1 Java: Generalities A little
More informationLecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University
Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types
More informationCOMP 102: Test August, 2017
Family Name:.......................... Other Names:.......................... Student ID:............................ Signature.............................. COMP 102: Test 1 14 August, 2017 Instructions
More informationWhere The Objects Roam
CS61A, Spring 2006, Wei Tu (Based on Chung s Notes) 1 CS61A Week 8 Where The Objects Roam (v1.0) Paradigm Shift (or: The Rabbit Dug Another Hole) And here we are, already ready to jump into yet another
More informationAnnouncements/Follow-ups
Announcements/Follow-ups Midterm #2 Friday Everything up to and including today Review section tomorrow Study set # 6 online answers posted later today P5 due next Tuesday A good way to study Style omit
More informationTwo Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.
Class #07: Java Primitives Software Design I (CS 120): M. Allen, 13 Sep. 2018 Two Types of Types So far, we have mainly been dealing with objects, like DrawingGizmo, Window, Triangle, that are: 1. Specified
More informationName Per. a. Make a scatterplot to the right. d. Find the equation of the line if you used the data points from week 1 and 3.
Unit 6 Review Name Per 1. How would you describe the relationship between the x- and y-values in the scatter plot? 90 80 70 60 50 0 '90 '95 '00 '05 '10 2. Based on the data in the scatter plot in #1, what
More informationCS-140 Fall 2017 Test 2 Version A Nov. 29, 2017
CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : An interface defines the list of fields
More informationQUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 27 th March
QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 27 th March 2006 11.05-12.35 Please fill in your Examination Number here: Student Number here: MODEL ANSWERS All
More informationCOMP 401 Fall Recitation 6: Inheritance
COMP 401 Fall 2017 Recitation 6: Inheritance Agenda Brief Review of Inheritance Examples of extending existing classes Exercises and Quiz 2 High-level Classes are Abstract Data Types We can define a set
More informationWarm-Up! Coding Bat Ap-1
Recursion Warm-Up! Coding Bat Ap-1 Lecture: Recursion! What will this code output? public int mystery(int max) { int answer = 1; for (int n = 1; n
More informationCOE318 Lecture Notes Week 9 (Week of Oct 29, 2012)
COE318 Lecture Notes: Week 9 1 of 14 COE318 Lecture Notes Week 9 (Week of Oct 29, 2012) Topics The final keyword Inheritance and Polymorphism The final keyword Zoo: Version 1 This simple version models
More informationCS-140 Fall 2018 Test 2 Version A Nov. 12, Name:
CS-140 Fall 2018 Test 2 Version A Nov. 12, 2018 Name: 1. (10 points) For the following, Check T if the statement is true, or F if the statement is false. (a) X T F : A class in Java contains fields, and
More information2.2 - Making Decisions
2.2 - Making Decisions So far we have only made programs that execute the statements in order, starting with the statements at the top of the screen and moving down. However, you can write programs that
More informationStrategies That Work
Email Strategies That Work Your focus questions for today: 1. What kinds of cookie content can I create? What type of content will reward my reader for consuming it? 2. When and how will I make an offer
More informationCSCI 1301: Introduction to Computing and Programming Summer 2018 Lab 07 Classes and Methods
Introduction This lab introduces you to additional concepts of Object Oriented Programming (OOP), arguably the dominant programming paradigm in use today. In the paradigm, a program consists of component
More informationNeed to store a list of shapes, each of which could be a circle, rectangle, or triangle
CS112-2012S-23 Abstract Classes and Interfaces 1 23-0: Drawing Example Creating a drawing program Allow user to draw triangles, circles, rectanlges, move them around, etc. Need to store a list of shapes,
More informationCS445 Week 9: Lecture
CS445 Week 9: Lecture Objectives: To discuss the solution of the midterm and answer any doubts about grading issues. Also, during the discussion, refresh the topics from the first part of the course. Reading
More information