Week 11 - Friday.  What did we talk about last time?  Object methods  Accessors  Mutators  Constructors  Defining classes.

Slides:



Advertisements
Similar presentations
Week 7: Input and Output 1.  Now we are going to talk a little bit about output  You have a lot of experience with System.out.println() and System.out.print()
Advertisements

Class Scope class Student { private: string id; string firstName, lastName; float gpa; public: void Read() { cin >> id >> firstName >> lastName >> gpa;
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Week 11 - Friday.  What did we talk about last time?  Object methods  Accessors  Mutators  Constructors  Defining classes.
TA: Nouf Al-Harbi NoufNaief.net :::
Week 10: Objects and Classes 1.  There are two classifications of types in Java  Primitive types:  int  double  boolean  char  Object types: 
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Stacks.
Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project.
1. 2 Introduction to Methods  Method Calls  Parameters  Return Type  Method Overloading  Accessor & Mutator Methods  Student Class: Revisited.
General Computer Science for Engineers CISC 106 Lecture 07 Dr. John Cavazos Computer and Information Sciences 2/25/2009.
Week 6 Recap CSE 115 Spring Review We have built a program that uses Association, Composition, Instantiation Dependency, Local Instance Dependency,
Repetition Structures: For Loop Constants CSC 1401: Introduction to Programming with Java Week 5 Wanda M. Kunkle.
Loops We have been using loops since week 2, our void draw(){ } is a loop A few drawbacks of draw() –It is endless –There is only one draw() –It updates.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 9 Objects and Classes.
AP Computer Science.  Not necessary but good programming practice in Java  When you override a super class method notation.
Slide 1. Slide 2 Administrivia Nate's office hours are Wed, 2-4, in 329 Soda! TA Clint will be handing out a paper survey in class sometime this week.
Introduction to Arrays CSC 1401: Introduction to Programming with Java Week 10 – Lecture 1 Wanda M. Kunkle.
Ping Zhang 10/08/2010.  You can get data from the user (input) and display information to the user (output).  However, you must include the library.
Week 10 - Monday.  What did we talk about last time?  Method overloading  Lab 9.
UML Basics & Access Modifier
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage  Weekly assignments.
Creating Simple Classes. Outline of Class Account Class Account Account # Balance Holder name phone# Overdrawn (true/false) Data Members Open Credit Debit.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Chapter 8. About the Midterm Exam.. Exam on March 12 Monday (Tentatively) Review on March 7 Wednesday Cover from Chapter 6 Grades will be out before spring.
Java Quiz Bowl A fun review of the Java you should know from CMPT 201 If you don’t know the answers - this week is for you to study up!
Week 9 - Monday.  What did we talk about last time?  Time  GDB.
CS177 RECITATION WEEK 7 Input and Output (Text & Graphical)
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
11 Introduction to Object Oriented Programming (Continued) Cats.
CSC 142 Computer Science II Zhen Jiang West Chester University
Two-Dimensional Arrays That’s 2-D Arrays Girls & Boys! One-Dimensional Arrays on Steroids!
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
CS1101: Programming Methodology Aaron Tan.
Java - Classes JPatterson. What is a class? public class _Alpha { public static void main(String [] args) { } You have been using classes all year – you.
CS305j Introduction to Computing Classes 1 Topic 23 Classes – Part I "A 'class' is where we teach an 'object' to behave." -Rich Pattis Based on slides.
Arrays.
Week 3 - Friday.  What did we talk about last time?  Operations on boolean values  !, &&, ||  Operations on char values  +, -  Operations on String.
Classes and Objects CS177 Rec 10. Announcements Project 4 is posted ◦ Milestone due on Nov. 12. ◦ Final submission due on Nov. 19. Exam 2 on Nov. 4 ◦
EGR 2261 Unit 11 Classes and Data Abstraction  Read Malik, Chapter 10.  Homework #11 and Lab #11 due next week.  Quiz next week.
Arithmetic, Class Variables and Class Methods Week 11
JAVA PROGRAMMING PART III. METHOD STATEMENT Form of method statement [ ] [static] ( [ ]) { } Example public static void main(String args[])
Introduction to Objects What is a constructor? Use type to create a variable Use class to create an object int x; Circle mycircle = new Circle ();
Week 5 - Wednesday.  What did we talk about last time?  Recursion  Definitions: base case, recursive case  Recursive methods in Java.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Types and Interfaces COMP.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
Week 12 - Friday.  What did we talk about last time?  Finished hunters and prey  Class variables  Constants  Class constants  Started Big Oh notation.
Week 12 - Wednesday.  What did we talk about last time?  Hunters and prey.
Week 12 - Monday.  What did we talk about last time?  Defining classes  Class practice  Lab 11.
Announcements Final Exam: TBD. Static Variables and Methods static means “in class” methods and variables static variable: one per class (not one per.
CS 5JA Introduction to Java Graphics One of the powerful things about Java is that there is.
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
Week 10 - Wednesday.  What did we talk about last time?  Method example  Roulette simulation  Types in Java.
Week 10 - Friday.  What did we talk about last time?  References and primitive types  Started review.
Week 10 - Monday.  What did we talk about last time?  Method overloading  Lab 9.
Week 6 - Friday.  What did we talk about last time?  Loop examples.
For Friday Read No quiz Program 6 due. Program 6 Any questions?
VG101 RECITATION 5 By TAs. CONTENTS How to read Vg101Class.h Samples about graphics About assignment 5 Array.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
CompSci Announcements  Read Chap 3 for next time  Homework will be posted  Consulting Hours will start soon.
Building Java Programs
Week 13: Searching and Sorting
Intro To Classes Review
Class Everything if Java is in a class. The class has a constructor that creates the object. public class ClassName private Field data (instance variables)
EECE.2160 ECE Application Programming
Instructor: Dr. Michael Geiger Spring 2019 Lecture 13: Exam 1 Preview
Ways to Check for Divisibility
Sequential Programming
Day 11 The Last Week!.
Presentation transcript:

Week 11 - Friday

 What did we talk about last time?  Object methods  Accessors  Mutators  Constructors  Defining classes

 Let’s create a Student class  Each Student will contain  First Name: String  Last Name: String  GPA: double  ID: int  We need a constructor specifying each of these things, accessors to read them later, and mutators to change GPA and ID

 Using the Student class, we can create a roster of students  The roster is just an array of Student objects  We’ll read in some student information from a file and create lots of Student objects  Then, with our array, we can do some operations:  Print out a nicely formatted roster  Find the average GPA of all students  Determine the valedictorian

 We can make a Ball class  Each Ball will have:  Color: Color  x Location: double  y Location: double  Radius: double  x Velocity: double  y Velocity: double  We will need a constructor specifying these values and a method to update the position of the ball over time

 With the Ball class created, it’s easy to make a program that shows balls bouncing all over the screen  We simply create an array of Ball objects and update them repeatedly

 Exam 2 post mortem  More object examples  Class variables and constants  Big Oh notation

 Keep working on Project 4  Due next Friday