CS 152 - Computer Science II
Spring-2020
Classes: TR 3:5 – 4:20pm, Maria Sanford Hall 221
Instructor: Dr. Fatemeh Abdollahzadeh, 30303 Maria Sanford Hall, (860)-832-2714,
http://www.cs.ccsu.edu/~abdollah/, e-mail: abdollah@ccsu.edu
Office hours: MW 4:20 to 4:30 in MS204 and MTWR
from 5:50 to 7 pm
Catalog description: Computer Science II Prereq.: CS
151 and MATH 152. Further topics in object-oriented programming: inheritance,
polymorphism, and Java interfaces. Event- driven programming. Elementary
searching and sorting techniques. Recursion. Design with UML diagrams.
Introduction to software engineering.
Prerequisites: CS 151 and MATH 152
Course Learning Outcomes:
- The students will learn to apply inheritance,
polymorphism, interfaces and abstract classes.
- The students will learn to design, implement, debug and
test non-trivial java applications (with multiple classes and/or
interfaces with methods requiring advanced algorithms).
- The students will learn to write Java applets and GUI
event driven stand-alone applications.
- The students will learn to write recursive methods with
integers,
arrays, and graphics.
- The students will learn to apply, trace, and informally
analyze linear and binary search and selection and insertion sorting
algorithms.
- The students will learn to implement and use linked
lists.
Program Educational Objectives: CS 152 is part of the core CS program and is designed in
accordance with the Program Educational Objectives and the Student Outcomes as
specified in the Department Mission Statement. The course Learning Outcomes support the following Student
Outcomes, which are part of the corresponding Program Educational Objectives:
- Graduates will have a broad understanding of the
fundamental theories, concepts, and applications of computer science.
- Outcome (a): An ability to apply knowledge of
computing and mathematics appropriate to the discipline.
- Outcome (b): An ability to analyze a problem, and
identify and define the computing requirements appropriate to its
solution.
- Outcome (c): An ability to design, implement, and
evaluate a computer-based system, process, component, or program to meet
desired needs.
- Graduates will be prepared for careers in computer
science and information technology.
- Outcome (k): An ability to apply design and
development principles in the construction of software systems of varying
complexity.
Required textbook: Lewis & Loftus, Java Software Solutions: Foundations of
Program Design, 8-th Edition, Addison-Wesley, 2015.
Required software: Blue J - an integrated Java programming environment (www.bluej.org) or any other java compiler like Eclipse.
Class Participation: Regular attendance and active class participation is expected from all
students. If you must miss a test, try to inform the instructor of this in
advance.
Assignments and tests: Reading and problem assignments are listed under the
schedule of classes. Some of the problems will be worked in class. There will
be quizzes, two tests and a final exam. They will include
material from the textbook, the lectures, and the programming projects.
Programming projects: There will be 6 programming projects requiring
the use of BlueJ to write and run Java programs. The
projects with their due dates are listed below in the schedule of classes. All
projects must be submitted at due day.
Grading: The final grade will be based on projects (40%), , tests (30%), and the final exam (30%), and
will be affected by classroom participation, conduct and attendance. The letter
grades will be calculated according to the following table:
A
|
A-
|
B+
|
B
|
B-
|
C+
|
C
|
C-
|
D+
|
D
|
D-
|
F
|
95-100
|
90-94
|
87-89
|
84-86
|
80-83
|
77-79
|
74-76
|
70-73
|
67-69
|
64-66
|
60-63
|
0-59
|
Unexcused late submission policy: Projects submitted more than two days after the due date
will be graded one letter grade down. Projects submitted more than a week late
will receive two letter grades down. No submissions will be accepted more than
two weeks after the due date.
Honesty policy: The CCSU honor code for Academic Integrity is in effect in
this class. It is expected that all students will conduct themselves in an
honest manner and NEVER claim work which is not their own. Violating this
policy will result in a substantial grade penalty, and may lead to expulsion
from the University. You may find it online at http://web.ccsu.edu/academicintegrity/. Please read it carefully.
Students with disabilities: Students who believe they need course accommodations based
on the impact of a disability, medical condition, or emergency should contact
me privately to discuss their specific needs. I will need a copy of the
accommodation letter from Student Disability Services in order to arrange class
accommodations. Contact Student Disability Services, Willard Hall, 101-04 if
you are not already registered with them. Student Disability Services maintains
the confidential documentation of your disability and assists you in
coordinating reasonable accommodations with your faculty.
Tentative
schedule of classes, assignments, projects and tests (by week)
Note: Due dates for classes, assignments, and
tests may change (see also University Calendar). Additional material may be posted. Check the schedule
regularly for updates!
- Jan 18, 30, Feb 2: Object Oriented Design and Arrays
- Topics:
- Review of Chapter 7: Static variables and methods,
Class relationships, The this reference, Method design
- Review of Chapter 8: Arrays
- Dynamic arrays (ArrayList
class)
- Object class
- Interfaces
- Lecture Slides: LEWIS_07.ppt, LEWIS_08.ppt
- Programs/Exercises:
- Static variables and methods: SloganCounter.java, Slogan.java (use a this reference in the constructor,
change variable count and method getCount()
to static/instance)
- Write class Person that has references to objects of
two other classes - Name and Address. Instantiate several objects of
class Person and count them using a static variable.
- Arrays: ReverseOrder.java, LetterCount.java
- Sorting arrays: array.java (create a method to print the array and use it to
trace sorting, use local variables and parameters or instance variables
and no parameters)
- ArrayList: Beatles.java
- Modify array.java to use ArrayList (need
casting or defining type of ArrayList, no need
of counting).
- Arrays of objects: index.java
- Object class and Interfaces: Students.java, Excellent.java, Ok.java, students.txt (Create interface Student and modify classes
Excellent and Ok to implement Student. Is casting needed?)
- ArrayList of objects: Students.java, Excellent.java, Ok.java, students.txt (Create an ArrayList and
fill it with Excellent and Ok objects. Use the instanceof operator
and casting to print the array. Define the ArrayList
of type Student. Is casting needed?)
- Assignments:
- Read Sections 5.6, 7.1 – 7.9, 8.1 – 8.6
- Run the programs and do the exercises described above
- Do Exercises: 7.2, 7.3, 7.5, 8.1, 8.4 – 8.10
- Do Programming Projects: 8.1, 8.3, 8.5, 8.6
- Feb 17: Submit Programming
Projects
- Feb 8 , 13 : Inheritance
- Topics:
- Creating subclasses and class hierarchies
- Overriding methods.
- Abstract methods and classes
- Lecture Slides: LEWIS_09.ppt
- Programs/Exercises:
- Students.java, Excellent.java, Ok.java, students.txt. Create class Student and make Excellent and Ok
subclasses of Student. Use "super" to call the Student
constructor and override the info() method.
- Make class Student abstract with abstract info() and non-abstract name(). In subclasses
Excellent and Ok, implement info() by using
name().
- Words.java, Dictionary.java, Book.java. Add a constructor to Dictionary (e.g Dictionary(int pages)),
create a new book class, e.g. Encyclopedia.java with constructor
Encyclopedia(int pages, int articles).
- Staff.java, Executive.java, Worker.java. Add toString() to print the type of worker (overriding methods)
or use super(name + " (executive)").
- library.zip (more elaborated book hierarchy).
- In library.java create objects from each class and
print them.
- Add constructor to class Book to set up the title
and pages (need to add/modify constructors to other classes).
- Add more programming books.
- Assignments:
- Read Sections 9.1 – 9.5
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 9.1-9.5, 9.9, 9.11-9.15
- Do Exercises: 9.3-9.5
- Do Programming Projects: 9.2, 9.3
- Feb 15, 20 ,22: Polymorphism and sorting
- Topics:
- Polymorphism (via inheritance and via interfaces)
- Object reference type casting
- Using the Comparable interface, Collections and
Arrays
- The sorting problem: selection, insertion and bubble
sorts
- Sorting arrays of objects
- Lecture Slides: LEWIS_10.ppt
- Programs/Exercises:
- Assignment:
- Read sections 10.1 – 10.4
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 10.1-10.16
- Do Exercises: 10.1, 10.4
- Do Programming Projects: 10.1, 10.2, 10.4
- March 20:
Submit Programming Project 2
- Feb 27: Searching
- Topics:
- Linear search
- Binary search
- Slides: LEWIS_10.ppt
- Programs/Exercises:
- searching-students.zip (search by name or by grade, evaluate complexity)
- Use Searching.java and Sorting.java to search a list
of 30 random numbers. Define an object Numb implementing the Comparable
interface and use a list of objects of this type.
- Assignments:
- Read Section 10.5 – 10.6
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 10.17-10.19
- Do Exercises: 10.1, 10.4
- Do Programming Projects: 10.1, 10.2, 10.4
- March 6:
Test #1
(Arrays, Inheritance, Visibility modifiers, Abstract classes, Polymorphism
and Sorting, Chapters 8, 9, 10).
- March 8: Review of Test 1 and Chapters 8, 9, 10
- March 20: Introduction to Graphics
- Topics:
- Introduction to graphics
- Writing simple applets
- Adding buttons and text fields to applets
- Writing GUI applications: containers, frames, panels
- Graphical objects
- Lecture Slides: LEWIS_02.ppt, LEWIS_03.ppt, LEWIS_04.ppt
- Programs/Exercises:
- Applets: Einstein.java, Pi1.java, Grades.java
- GUI applications, frames, panels: Authority.java (add nested panels)
- Graphical objects:
- Extend JPanel
- Define constructor to set the basic properties (e.g.
setPreferredSize, setBackground)
- Override paintComponent(Graphics page): call super.paintComponent(page)
and draw objects (e.g. page.drawString(...), page.drawLine(...))
- Assignments:
- Read Sections 2,7 – 2.9, 3.9 – 3.11, 4.6 – 4.9
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 2.42 - 2.47, 3.36 -
3.39, 4.30 - 4.35
- Do Exercises: 2.16 - 2.18
- Do Programming Projects: 3.10, 3.11, 4.14 - 4.16
- March 22, 27 : More Graphics
- Topics:
- Drawing with loops and conditionals
- Events and listeners
- Determining event sources
- More GUI objects: buttons, dialog boxes, check boxes,
and radio buttons
- Lecture Slides: LEWIS_04.ppt, LEWIS_05.ppt
- Programs/Exercises:
- Drawing with loops and conditionals: PiFrame.java, PiSquare.java
- Events: PushCounter.java, PushCounterPanel.java (add a Clear button with another listener class).
Note the nested class definitions and privite
classes.
- Determining event sources: LeftRight.java, LeftRightPanel.java (add buttons directly to LeftRightPanel,
implement two listener classes)
- Dialog boxes: Guess.java (use class JOptionPane to
create dialog boxes for prompting the user)
- Reading a text field: CopyText.java, CopyTextPanel.java (add a listener to the text field, implement some
statistics on the input text, implement Guess.java with a text field)
- Check boxes and Radio buttons: StyleOptions.java, StyleOptionsPanel.java, QuoteOptions.java, QuoteOptionsPanel.java (take off the button group, see what the event is)
- Assignments:
- Read Sections 5.7 – 5.8, 6.5 – 6.6
- Run the programs and do the exercises described above
- April 17:
Submit Programming Project 3
- March 29: GUI Design
- Topics:
- GUI design
- Layout managers
- Containment hierarchies
- Lecture Slides: LEWIS_07.ppt
- Programs/Exercises:
- Run layout.zip
- Add different layouts to LeftRight.java,
StyleOptions.java and QuoteOptions.java.
- Assignments:
- Read Sections 7.10 – 7.13
- Run the programs and do the exercises described above
- April 3: Polygons and polylines
- Topics: Polygons and polylines
- Lecture Slides: LEWIS_08.ppt
- Programs/Exercises:
- Assigmenent:
- Read Section 8.7
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 8.12-8.27
- Do Programming Projects: 8.12-8.16
- April 5, 10 ,12: Mouse and Key Events
- Topics: Mouse events and key events.
- Lecture Slides: LEWIS_08.ppt
- Programs/Exercises:
- Mouse events: Dots.java, DotsPanel.java. Connect dots with lines, draw dots by dragging the
mouse, add a button to clear the panel, add a button to remove dots, use
the distance function.
- Lines and distances: RubberLines.java, RubberLinesPanel.java. Compute the distance from the moving point to the
line using Line2D and Line2D.Double classes and ptLineDist
and ptSegDist methods.
- Key Events: Direction.java, DirectionPanel.java. Define different arrow classes that implement an
arrow interface and draw the arrows using polymorphic references)
- Interactive trigonometry: trigonometry.zip, (see http://en.wikipedia.org/wiki/Trigonometric_function, http://en.wikipedia.org/wiki/Arctangent, http://mathworld.wolfram.com/Collinear.html). Add an arrow at the end of the line in Angle.java
(use the arrow from Direction.java).
- Drawing and representing graphs: Graph.java, GraphPanel.java
- Using graphs: Social Networks and PageRank, PowerIteration.java (ses also http://en.wikipedia.org/wiki/Eigenvector)
- Assignment:
- Read Sections 8.8 – 8.9
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 8.28-8.31, 8.33, 8.34
- Do Exercises: 8.12-8.15
- Do Programming Projects: 8.19-8.23
- April 17: Adapter classes, event processing
- Topics:
- Extending adapter classes
- Event processing and polymorphism
- Lecture Slides: LEWIS_09.ppt, LEWIS_10.ppt
- Programs/Exercises:
- Assignments:
- Read Sections 9.7, 9.8, 10.7 – 10.10
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 9.23 - 9.30
- April 19:
Test #2
(GUI applications)
- April 24: Exceptions
- Topics:
- Exceptions and exception handling
- The try-catch statement
- Exception propagation
- Lecture Slides: LEWIS_11.ppt
- Programs/Exercises: Exceptions.java, CaughtExceptions.java, Divide.java, Add.java, IntegerOverflowException.java
- Add try-catch in Divide
- Add try-catch in Exceptions
- Define a class to check the number format (use Integer.parseInt(String) and NumberFormatException)
- Assignments:
- Read Chapter 11
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 11.1 - 11.9
-
- April 26, May 1: Recursion
- Topics:
- Recursive 1 programming
- Recursion versus iteration
- Recursive functions
- Recursive data structures, list processing
- Problem solving
- Tree/Graph search
- Lecture Slides: LEWIS_12.ppt
- Programs/Exercises:
- Functions: Fact1.java, Fact2.java, Fibonacci1.java, Fibonacci2.java, implement gcd(a,b): {gcd(a,0)=a; gcd(a,b)=gcd(b,a%b)}
- Recursive list processing: List.java, Lists.java
- Recursive lists: class List {int head; List tail}. List
list = new List(1,new List(2,new
List(3,null)));
- List membership: boolean
member (int x, List list) { if (list==null) return false; else if (x==list.head) return true; else return member(x,list.tail); }
- Problem solving: MazeSearch.java,
Maze.java,
Maze1.java
(all solutions), Farmer.java,
State.java
- Tree/Graph Search: Path.java, use rescursive list to
store the path, AllPaths.java, find the shortest path by iterative deepening
-
- Assignments:
- Read Sections 12.1 – 12.3
- Run the programs and do the exercises described above
- Answer Self-Review Questions: 12.1 - 12.13
- Do Exercises: 12.1 - 12.8
- Do Programming Projects: 12.1 - 12.3
- May 3:
Submit Programming Project 4
- May 3: Linked Lists
- Topics:
- Collections and data structures
- Dynamic representations
- Linked lists
- Lecture Slides: LEWIS_13.ppt
- Programs/Exercises: LinkedList.java
- Define methods size(), get(int index), and set(int
index, int item)
- Add a pointer to the end of the list and rewrite the
add method
- Add a pointer to the previous node (doubly-linked
list) and traverse the list in reverse order
- Assignments:
- Read Sections 13.1, 13.2
- Run the programs and do the exercises described above
- Answer Self-Review Questions: TBA
- Do Exercises: TBA
- Do Programming Projects: TBA
- If
There is time
- Topics:
- Recursion in graphics
- Review of Final Exam
- Lecture Slides: LEWIS_12.ppt
- Programs/Exercises: Quadtree.java, QuadtreePanel.java (see http://en.wikipedia.org/wiki/Quadtree)
- Assignments:
- Read Section 12.4
- Run the programs and do the exercises described above
- Answer Self-Review Questions: TBA
- Do Exercises: TBA
- Do Programming Projects: TBA
- Final Exam (includes all topics, textbook sections, and
programs listed in the syllabus except for Graphics)