From charlesreid1

Line 16: Line 16:
(Recommended) Self-check problems: #7, #10, #15, #18, #21, #26
(Recommended) Self-check problems: #7, #10, #15, #18, #21, #26


(Required) Exercises: #3, #4, #5, #6, #14, #15, #16, #17
(Required) Exercises: #3, #4, #5, #6, #14, #15, #16


(Required) Projects: (none)
(Required) Projects: (none)
Line 23: Line 23:


Self-check:
Self-check:
* 7 - create Name class, first/middle/last
* 10 - distance method to Point object
* 15 - tSoString method to Name class
* 18 - constructor problems
* 21 - constructor to Point class accepting Point
* 26 - encapsulate Name class


Exercises:
Exercises:
* 3 - add manhattanDistance() method to Point class
* 4 - add isVertical() method to Point class
* 5 - add slope() method to Point class
* 6 - add isCollinear() method to Point class
* 14 - Line class between two points, implement specified constructors and methods
* 15 - add getSlope() method to Line class
* 16 - add Line constructor


Projects:  
Projects:
* none


==Chapter 8 Code==
==Chapter 8 Code==

Revision as of 01:25, 20 September 2016

Chapter 8: Object Oriented Programming (Review)

Chapter 8 Summary

Chapter 8 concepts:

  • Object oriented programming (classes and objects)
  • Object state (fields) and behavior (methods); accessors
  • Object initialization (constructors)
  • Encapsulation (private fields)
  • Case study: Stock class

Chapter 8 Homework

HW Questions

(Recommended) Self-check problems: #7, #10, #15, #18, #21, #26

(Required) Exercises: #3, #4, #5, #6, #14, #15, #16

(Required) Projects: (none)

HW Details

Self-check:

  • 7 - create Name class, first/middle/last
  • 10 - distance method to Point object
  • 15 - tSoString method to Name class
  • 18 - constructor problems
  • 21 - constructor to Point class accepting Point
  • 26 - encapsulate Name class

Exercises:

  • 3 - add manhattanDistance() method to Point class
  • 4 - add isVertical() method to Point class
  • 5 - add slope() method to Point class
  • 6 - add isCollinear() method to Point class
  • 14 - Line class between two points, implement specified constructors and methods
  • 15 - add getSlope() method to Line class
  • 16 - add Line constructor

Projects:

  • none

Chapter 8 Code

Lecture Code

We have a simple object-oriented hello world program implemented in the 00_HelloWorld folder in the Github repository.

Worksheet Code

Polynomials:

  • In this assignment, you'll implement a Polynomial object and use it in a PolynomialDriver class
  • You should plan out your data structure for a polynomial object (what fields are necessary?)
  • You should design your class to implement methods as specified in assignment:
  • Implement 3 methods:
    • Add one polynomial to another, and return a new Polynomial object as the result (returns a Polynomial)
    • Evaluate the polynomial at a particular location x (returns a double)
    • Add a toString() method that will print out the polynomial like 5.0 x^2 + 1.123 x + 17.9

Polynomial Driver:

  • Adding:
    • Create the polynomial 4 x^3 + x^2 + 4 x + 1
    • Create the polynomial x^2 + 2x + 1
    • Add these two polynomials to get result 4 x^3 + 2 x^2 + 6 x + 2
    • Print the result
  • Evaluating:
    • Create the polynomial


Extra credit:

  • Implement subtraction method that utilizes the add method (+2)
  • Implement root-finding method for polynomials with degree < 3 (+5)
  • Implement root-finding method for polynomials with arbitrary degree (+10)

Chapter 8 Goodies

Puzzle 1

Java encoded with Caesar cipher

Puzzles/Crypto Level 2/Puzzle 1

Profiles

James Gosling

  • Inventor of Java


Flags