|
Computer Science Classes at Marshfield High School |
How to Download GridWorld.
First unzip the GridWorld.zip file it into your Eclipse workspace. Don't make a directory the zip will make it for you. This directory will be called GridWorldCode. In Eclipse create a java project called GridWorldCode. Then run firstProject - BugRunner as a Java Application.
ResourcesJava Concepts, Cay Horstmann
Be Prepared for the AP Computer Science Exam in Java, Maria Litvin
AP Java - Maria Litvin
www.eimacs.com
GridWorld - AP Collegeboard
- Unit 1 - Introduction to Java and Object Oriented Programming
- For the first half of the school year the class will be divided into groups based on each student's level of comfort with java. The group you are assigned to is fluid, and is based on both the students and my opinion.
- Introduction to class
- Objective - is to introduce the tools that we will be using in the class
- Lesson 2
- Read Chapter 1
- eIMACs - Introduction ->Welcome
- Everyone
- Tools - (Eclipse - Java sdk 5)
- set up Eclipse and compile and run "Hello World"
- find the College Board Site and get to know it
- find the javaBat link and do a quick exercise
- go through all links on Web site. - READ THEM
- Assessment - Graded as a Lab Assignment
- Lesson 3 9/8
- Objective Review Introduction to Java - JVM, Primitives and Casting
- In Journal
- Create a pathname for journal H:/APJava/journal/firstInitialLastnameJournal.doc
- put date and include what you accomplished:
- Ran a program in Eclipse on the H drive in a directory called H:/APJava/workspace
- Found the College Board site
- Found and done one exercise in JavaBat
- Gone through the links on the Web site.
- Objective - How the Java Run Time Environment Works and memorize the 8 Java Primitives
- Lecture
- JVM- A program written in Java receives services from the Java Runtime Environment (JRE) software by issuing commands to, and receiving the expected results from, the Java software. By providing these services to the program, the Java software is acting as a "virtual machine", taking the place of the operating system or hardware for which the program would ordinarily be tailored. from the Wikipedia explanation of the Java Virtual Machine - read more of this
- 8 Primitive data types in java
byte 0 short 0 int 0 long 0L float 0.0f double 0.0d boolean false char '\u000' - Casting is converting one data type to another. There is two kinds of casting one between primitives numeric types and Objects. Casting between primitives numeric types is used to convert larger values, such as double values, to smaller values such as doubles to integers. For Objects All classes are child classes of java.lang.Object, so you can freely cast any class to Object class, or any class within the same family.
- Link to Chapter One Power Point Slides
- Objective - If you know the java primitive and conversion rules you are guaranteed a certain amount of correct answers on the test
- Computer
- review of Coding Guidelines Java Language Coding Guideline
- Eimacs AP Java online Course eimacs.com
- All exercises and tests through and including Test 2
Lesson 4 - 9/14 and 9/16
For each Class write in your journal at the beginning and the end of class.
What you want to achieve at the beginning of the class End the daily journal with what youachieved.
- I will be reading these daily-
- Assignment 1
- Finish Emac through test 2
- Joe first do the following programming exercises P1.1, P1.2, P1.3, P1.4, and P1.5 in Chapter 1 of Big Java. After you've completed the programs then move on to Emac.
- Assignment 2- Chapter 2
Types of Variables in Java - link to java.sun.com tutorials - Make sure you know the difference betweenn these types of variables
Instance Variables (Non-Static Fields) Class Variables (Static Fields) Local Variables Parameters A type's fields, methods, and nested types are collectively called its members. Chapter 2 Using Objects - READ CHAPTER 2 - REALLY READ IT!
- Programming Exercise P2.10 in Chapter 2 of Big Java.
Monday 9/2 and I'm still out I've included a Link to the Chapter 3 Power Point
Lesson 5 - 9/18, 9/22, 9/24, 9/28 and 9/30 Keep going
- Journal
Students are to update their journals at the beginning of the class with what they hope to accomplish during the class. At the end of each class students should again update their journals with what they did accomplish. Computer
- If students have not finished Lesson 4 this should be their priority.
Students should continue with Emacs test 3 through 5 Chapter 3 Horstmann -Implementing Classes
Complete the following exercises
Review Questions 3.1 and 3.2 Programming Exercises 3.5, 3.6, 3.8, p3.9 , p3.11, 3.12 Chapter 4 - Fundamental Data Types,
Programming Problems P4.11, P4.12, P.17 and P4.18 and P4.18 If any of you finish before I come back continue with Emac 6 through 11 (give recursion a try!) Read Chapter 1 and 2 in Be Prepared for the AP Computer Science Exam in Java Take first practice ap test Test - on all topics covered in Unit 1 and 2Lesson 6 - Week of 10/22
Complete the following exercises
Review Questions 3.1 and 3.2 Programming Exercises 3.5, 3.6, 3.8, p3.9 , p3.11, 3.12 Chapter 4 - Fundamental Data Types,
Programming Problems P4.11, P4.12, P.17 and P4.18 and P4.18 If any of you finish before I come back continue with Emac 6 through 11 (give recursion a try!) Read Chapter 1 and 2 in Be Prepared for the AP Computer Science Exam in Java Take first practice ap test Test Nov 2nd All material to date - Horstmann chapters 1 through 4, Emac tests 1 through 5, and AP be Prepared Unit 1 and 2 (Litvin) In addition to the test you will be graded on:
- Programming Problems in Chapter 3 and Chapter 4 - code should be commented and correct!
- Completion of Emacs through test 5
Lesson 6 Week of 11/9Continue to finish Chapter 3, 4 and 8 problems. This includes reading the Chapters at homeRead Chapter 1 and 2 in Be Prepared for the AP Computer Science Exam in Java and do the exercisesIf any of you finish before I come back continue with Emac 6 through 11 (give recursion a try!)Know Table 1 Primitive Type Chapter 4Horstmann, Java Book, Chapter 2 Number Types
Java has separate types for integers and floating-point numbers . Integers are whole numbers; floating-point numbers can have fractional parts. For example, 13 is an integer and 1.3 is a floating-point number.
The double type denotes floating-point numbers that can have fractional parts.The name “floating-point” describes the representation of the number in the computer as a sequence of the significant digits and an indication of the position of the decimal point. For example, the numbers 13000, 1.3, 0.00013 all have the same decimal digits: 13. When a floating-point number is multiplied or divided by 10, only the position of the decimal point changes; it “floats”. This representation is related to the “scientific” notation 1.3 × 10-4. (Actually, the computer represents numbers in base 2, not base 10, but the principle is the same.)
If you need to process numbers with a fractional part, you should use the type called double, which stands for “double precision floating-point number”. Think of a number in double format as any number that can appear in the display panel of a calculator, such as 1.3 or -0.333333333.
Do not use commas when you write numbers in Java. For example, 13,000 must be written as 13000. To write numbers in exponential notation in Java, use the notation En instead of “×10n”. For example, 1.3 × 10-4 is written as 1.3E-4.
You may wonder why Java has separate integer and floating-point number types. Pocket calculators don't need a separate integer type; they use floating-point numbers for all calculations. However, integers have several advantages over floatingpoint numbers. They take less storage space, are processed faster, and don't cause rounding errors. You will want to use the int type for quantities that can never have fractional parts, such as the length of a string. Use the double type for quantities that can have fractional parts, such as a grade point average.
Horstmann Java Book, Chapter 4 Number Types 4.1(for more information read advanced topic 4.1, 4,2 and Random fact 4.1)Numerical Computational OverflowsA numeric computation overflows if the result falls outside the range for the number type.
Each of the integer types has a different range—Advanced Topic 4.2 explains why the range limits are related to powers of two. Generally, you will use the int type for integer quantities. However, occasionally, calculations involving integers can overflow. This happens if the result of a computation exceeds the range for the number type. For example:
int n = 1000000;
System.out.println(n * n); // Prints-727379968The product n * n is 1012, which is larger than the largest integer (about 2 · 109). The result is truncated to fit into an int, yielding a value that is completely wrong. Unfortunately, there is no warning when an integer overflow occurs.
If you run into this problem, the simplest remedy is to use the long type. Advanced Topic 4.1 shows you how to use the arbitary-precision BigInteger type in the unlikely event that even the long type overflows.
Overflow is not usually a problem for double-precision floating-point numbers. The double type has a range of about ±10308 and about 15 significant digits. However, you want to avoid the float type—it has less than 7 significant digits. (Some programmers use float to save on memory if they need to store a huge set of numbers that do not require much precision.)
Rounding errors occur when an exact conversion between numbers is not possible.Rounding errors are a more serious issue with floating-point values. Rounding errors can occur when you convert between binary and decimal numbers, or between integers and floating-point numbers. When a value cannot be converted exactly, it is rounded to the nearest match. Consider this example:
double f = 4.35;
System.out.println(100 * f); // Prints 434.99999999999994This problem is caused because computers represent numbers in the binary number system. In the binary number system, there is no exact representation of the fraction 1/10, just as there is no exact representation of the fraction 1/3 = 0.33333 in the decimal number system. (See Advanced Topic 4.2 for more information.)
For this reason, the double type is not appropriate for financial calculations. In this book, we will continue to use double values for bank balances and other financial quantities so that we keep our programs as simple as possible. However, professional programs need to use the BigDecimal type for this purpose —see Advanced Topic 4.1.
In Java, it is legal to assign an integer value to a floating-point variable:
int dollars = 100;
double balance = dollars; // OKBut the opposite assignment is an error: You cannot assign a floating-point expression to an integer variable.
double balance = 13.75;
int dollars = balance; //ErrorTo overcome this problem, you can convert the floating-point value to an integer with a cast:
int dollars = (int) balance;
You use a cast (typeName) to convert a value to a different type.The cast (int) converts the floating-point value balance to an integer by discarding the fractional part. For example, if balance is 13.75, then dollars is set to 13.
The cast tells the compiler that you agree to information loss, in this case, to the loss of the fractional part. You can also cast to other types, such as (float) or (byte).
Use the Math.round method to round a floating-point number to the nearest integer.If you want to round a floating-point number to the nearest whole number, use the Math.round method. This method returns a long integer, because large floating-point numbers cannot be stored in an int.
long rounded = Math.round(balance);
If balance is 13.75, then rounded is set to 14.
11/22 Add Scanner Class to 4.11 or 8.3 Horstmann Java Book, 4.7
After Vacation - Stop What you are Doing and Start2 weeks - 1/5 - 1/18
- At home - Read Chapter 5 (Conditionals) and Chapter 6 (Iterations) - Horstmann
- Up front in class do - Exercises R5.9, R5.10 and R5.14
- Programming Exercises P5.2
- Emac - Labs and Tests 6 (Program Control), 7 (While Loops), and 8 (For Loops)
- Exercises P6.3, P6.4 and P6.5
Array Lists For Vacation
- Link to Term2 test with Answers
- Link to Array and ArrayList test with Answers
- Chapter 7 ArrayLists
- 2/1 Continue coding Arrays and Arraylist in JavaBat or where you find most helpful. I can give you short problems to solve if you like.
- JavaBat
- Home work read Chapter 13 on Recursion Test on Tuesday 9th.
- Link to Tutorials
Review 2/22
- ArrayList test
- ArrayList methods and Facts
- ArrayLists <String> myArrayList = new ArrrayList <String>();
- No Primitives
- add(E o) - appends to the end of this list
- add(int index, E element) - inserts the specified element at the specified position in the list)
- clear() - removes all elements from the list
- contains(object elem) - Returns true if this list contains a specfied element
- get(int index) - Returns the element at the specified position in the list
- indexOf(Object elem) - Searches the first occurence of the given argument, testing for equality using the equals method
- Iterator <E> iterator() - Returns an iterator over the elements in this list in proper sequence.
- isEmpty() - Tests if this list has no elements
- public interface ListIterator extends Iterator -An iterator for lists that allows the progrmmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator;s current position in the list. A ListIteratior has not current element; its cursor position alsways lies between the element that would be returned by a call to previouus() and that would be returned by a call to next(). In a list of length n, there are n+1 values, from 0 to n, inclusive.
- remove(int index) - Removes the element at the specified position in this list.
- remove(Object o) - Removes a single instance ofthe specified element from the list, if it is present (optional operation)
- set(index, E element) - Replaces the number of elements in this list
- size() - Returns the number of elements in the list.
- Examples of wrapper Classes
- Integer
- Double
- Autoboxing and Auto-Unboxing - automaticall wraps and unwraps primitives. (You don't need to cast ints)
- Vocabulary to know
- Array
- ArrayIndexOutofBoundsException
- Autoboxing and Auto-unboxing
- Collection
- Dynamic Array
- Element
- Generics
- Index
- Linear search
- Interface List <E> - In Java list is a collection that remembers the order of its elements. (Cay Horstmann- Java for Everyone)
- ListIterator
- TraversiJng
- Type parameter
- Wrapper class
Sorting and Searching
3/4 - 3/19 (Searching and Sorting, Comparable Interface, and Generics)
- Chapter 14
- Sorting - P14.2, P14.4,
- Searching - P14.8
- Analyzing the Performance of Sort Algorithms (You are responsible for knowing this)
- Test on Searching and Sorting 3/12
- ***Great Visuals of How Sorting Algorithms Work **
- ***Link to Great Visuals of How Sorting Algorithms Work **
- Comparator Interface A Class - 14.13
- Link to sun discussion on Generics - at the bottom of page click on the tutorial and skim through sections 1 through 5.
- Prepare for test on Searching and Sorting by working on some Emac problems
**Code for Selection, Bubble, and Insertion **
Homework Assignments due 3/16 -
Test 3/18 on code for Select, Bubble, Insertion, and Merge Sort - In addition will be asked Big-Oh questions.
Completion of your homework is part of your grade, and will be considered a lab assignment. Lab assignments are worth %15 of your grade
- Joe, Nick, and Keith Emacs AP Computer Science - Java Programming - due 3/16 read Iterations - While and For Loops and take tests 7 and 8.
- Jon, Dan, Chris, and Michael Emac Be Prepared for AP Test due 3/16 Chapters 1 through 5 and take test 1 at home - I want to receive email for each Chapter you finish.
3/22 First half of AP Test
3/24 - 4/16 GridWorld
- Grid World Chapter 3 , Question Sets 3 through Set 6.
- ***Link to GridWorld Homework**
- Javadoc for GridWorld
- Link to MUST READ GRIDWORLD Notes by Cay Horstmann
4/16 GridWorld Test
4/27 Second Half of AP Test
4/29 - 5/7 Testing, Testing and Testing
*******************************************************************************************************************************
- Vocabulary
- Encapsulation
- Polymorphism
- API Documentation
- accessor and mutator
- class
- constructor
- implicit parameter
- parameter
- method
- new
- object and object reference
- overloading
- primitive type
Important Links
The Google Highly Open Participation Contest / Open Source Projects new link
GridWorld Quick Reference new link
The unofficial AP Java Schedule new link
Bank Account Example and Bank Account Tester
JavaBat- Java Practice Problems
AP Java online Course eimacs.com
Sun Java API's 1.5.0
Java cscie160 -For Distributed Programming
College Board Information
Sun the Really Big Index
Sun OO Tutorials
Sun Java Package Tutorial
How to Write Doc Comments for the Javadoc Tool
Java Language Coding Guidelines
Lessons
- Merge and Merge Sort
- Quadratic Sorting Algorithms
- Recursive Array Programming
- Two Dimensional Array Programming
- ArrayList Tutorial
- Array Tutorial
- Boolean Algebra
- Exceptions Tutorial
- Recursion Tutorial
- Defining and Using Classes
- More about Methods
- Structured Programming
- While Loops
- More on Loops
- Switch Statements
- Object References
- Strings
- Inheritance
Object Oriented Vocabulary List
Encapsulation Polymorphism API Documentation accessor and mutator class constructor implicit parameter parameter method new object object reference overloading primitive typeImportant Links
3D Mandelbrot (fractal) images
Marble Madness - Understanding Binary Math
***Sorting Code - Side by Side - Selection - Bubble - Insertion *
Bank Account Example and Bank Account Tester
Sun Java API's 5 (the test is still using version 5 of the api)
Java cscie160 -For Distributed Programming
College Board Information
Sun the Really Big Index
Sun OO Tutorials
Sun Java Package Tutorial
Link to Horstmann Chapter 1 power point
How to Write Doc Comments for the Javadoc Tool
Java Language Coding Guidelines