No class on Wednesday, December 9
Take Quiz 4 online in Blackboard: December 7-9
Project 6 is due on December 10
Final Exam: December 14, 8:00am 10:00am
CS 152 - Computer Science II (Section 01)
Fall-2015
Classes: MW 9:25am 10:40am, Maria Sanford Hall 221
Instructor: Dr. Zdravko Markov, 30307 Maria Sanford Hall, (860)-832-2711,
http://www.cs.ccsu.edu/~markov/, e-mail: markovz at ccsu dot edu
Office hours: MW 12:15pm 1:00pm; TR 9:30am 10:30am, 12:15pm 1:00pm
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, wnich 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: BlueJ - an integrated Java programming environment
(www.bluej.org)
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 through the class page in Blackboard Learn course management
system at https://ct-ccsu.blackboard.com/.
Grading: The final grade will be based on projects (50%),
quizzes
(10%),
tests (20%), and the final exam (20%), 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 Registration
Calendar). Additional material may be posted. Check the schedule regularly
for updates!
-
August 31, September 2, 9: 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.
-
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)
-
Arrays: ReverseOrder.java,
LetterCount.java
-
ArrayList: Beatles.java
-
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
-
September 1013: Take Quiz 1 online in Blackboard
-
September 16: Submit Programming
Project 1
-
September 14, 16: 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.
-
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
-
September 21, 23: Polymorphism and sorting
-
Topics:
-
Polymorphism (via inheritance and via interfaces)
-
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
-
September 30: Submit Programming
Project 2
-
September 28, 30: 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
-
September 2829: Take Quiz 2 online in Blackboard
-
October 5: Test #1 (Arrays, Inheritance, Polymorphism
and Sorting, Chapters 8, 9, 10).
-
October 7: No class
-
October 12: 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:
-
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
-
October 14, 19: More Graphics
-
Topics:
-
Drawing with loops and conditionals
-
Determining event sources
-
More GUI objects: dialog boxes, check boxes, and radio buttons
-
Lecture Slides: LEWIS_05.ppt
-
Programs/Exercises:
-
Assignments:
-
Read Sections 5.7 5.8, 6.5 6.6
-
Run the programs and do the exercises described above
-
October 21, 26: 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
-
November 2: Submit Programming
Project 3
-
October 28: 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.25-8.27
-
Do Programming Projects: 8.12, 8.16
-
November 2, 4: Mouse and Key Events
-
Topics: Mouse events and key events.
-
Lecture Slides: LEWIS_08.ppt
-
Programs/Exercises:
-
Mouse events: Dots.java,
DotsPanel.java,
RubberLines.java,
RubberLinesPanel.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).
-
Key Events: Direction.java,
DirectionPanel.java
(define different arrow classes that implement an arrow interface and draw the arrows using polymorphic references)
-
Drawing and representing graphs: Graph.java,
GraphPanel.java
-
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).
-
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
-
November 9, 11: 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
- November 910: Take Quiz 3 online in Blackboard
-
November 18: Submit Programming
Project 4
-
November 16: Test #2 (Applets and GUI
applications)
-
November 18: Exceptions
-
November 23, 30, December 2: Recursion
-
Topics:
-
Recursive programming
-
Recursion versus iteration
-
Recursive functions
-
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)}
-
Lists: List.java,
Lists.java
(see http://en.wikipedia.org/wiki/Prolog,
Quick
Introduction to Prolog), QuickSort.java
(see http://en.wikipedia.org/wiki/QuickSort).
-
Problem solving: Maze.java,
MazeSearch.java,
Farmer.java,
State.java
-
Tree/Graph Search: Path.java,
AllPaths.java, find the shortest path by iterative deepening
-
Assignments:
-
Read Sections 12.1 12.3, 13.1 13.4
-
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
-
December 10: Submit Programming
Project 6
-
December 7: Recursion in graphics
- December 9: No Class. Take Quiz 4 online in Blackboard
-
December 14, 8:00am 10:00am: Final Exam (includes all
topics, textbook sections, and programs listed in the syllabus)
Programming Project 1
Log on to Blackboard
Learn to see and submit the project.
Programming Project 2
Log on to Blackboard
Learn to see and submit the project.
Programming Project 3
Log on to Blackboard
Learn to see and submit the project.
Programming Project 4
Log on to Blackboard
Learn to see and submit the project.
Programming Project 5
Log on to Blackboard
Learn to see and submit the project.
Programming Project 6
Log on to Blackboard
Learn to see and submit the project.
Test 1 Sample Problems
1) What does the following code do? Assume list is an array of int
values, temp is some previously initialized int value, and c is an int
initialized to 0.
for (int j = 0; j < list.length; j++)
if (list[j] < temp) c++;
a) It finds the smallest value and stores it in temp
b) It finds the largest value and stores it in temp
c) It counts the number of elements equal to the smallest value in
list
d) It counts the number of elements in list that are less than temp
e) It sorts the values in list to be in ascending order
2) An int array stores the following values (in that order): 9,
4, 12, 2, 6, 8, 18
a) Demonstrate how the array is sorted in ascending order by
the Selection sort algorithm. Show the content of the array after each
pass of the outermost loop of the algorithm.
b) Demonstrate how the array is sorted in ascending order by the Insertion
sort algorithm. Show the content of the array after each pass of the outermost
loop of the algorithm.
3) The code below adds elements to an array of objects Numbers and
then prints the array. Add declarations for: Numbers, x, gen, and n, and
define the class Num with the minimum information so that the code below
runs. Hint: gen is an instance of the Random class.
for (int i = 0; i < 10; i++)
{
x = gen.nextInt(100);
Num n = new Num (x);
Numbers.add(n);
}
for (int index = 0; index < Numbers.size();
index++)
System.out.println (Numbers.get(index));
4) The following program generates a list of parts each one defined
with a name and an ID. Then it finds the ID of the part named Part 4
and prints its ID. Define the class Part accordingly. Hint: Part must implement
the Comparable interface (defining properly compareTo) and should also
include a constructor and a method toString().
public class Items
{
public static void main (String[] args)
{
Part [] list = new Part[6];
Part target = new Part ("Part 4",
0);
list[0] = new Part ("Part 1", 123);
list[1] = new Part ("Part 2", 127);
list[2] = new Part ("Part 3", 531);
list[3] = new Part ("Part 4", 131);
list[4] = new Part ("Part 5", 789);
list[5] = new Part ("Part 6", 254);
for (int i = 1; i < list.length;
i++)
if (list[i].compareTo(target)
== 0)
System.out.println(list[i]);
}
}
5) Consider the following partial class definitions:
public class A
{
public int x1;
private int y1;
protected int z1;
}
public class B extends A
{
public int x2;
private int y2;
protected int z2;
}
public class C extends A
{
public int x3;
private int y3;
}
public class D extends B
{
public int x4;
private int y4;
}
a) Draw a diagram showing the class hierarchy.
b) Explain the visibility (accessibility) of all variables.
Test 2 Review Topics
-
Applets
-
GUI applications
-
Objects: frames, panels, dialog boxes, check boxes, and radio buttons
-
Events, event sources: ActionListener, MouseListener, MouseMotionListener
interfaces
-
Event processing using the Adapter class: MouseAdapter, MouseMotionAdapter
(see AnglePanel.java,
Angle.java)
-
Programs: Authority.java,
PiFrame.java,
PiSquare.java,
Guess.java,CopyText.java,
CopyTextPanel.java,
StyleOptions.java,
StyleOptionsPanel.java,
QuoteOptions.java,
QuoteOptionsPanel.java
-
Polygons and polylines