CS 152: Computer Programming Fundamentals
in Java

Computer Science Department
University of New Mexico

Instructor:
Joel Castellanos
Department of Computer Science
e-mail: joel@unm.edu

Course Description
CS-152 offers a solid foundation in the art of computing. For most students, CS-152 should not be a first course in computer programming, but should only be taken after being familiar with writing computer programs in Java or some other computer language such as Python, MATLAB, C/C++, Fortran, or BASIC. That said, CS-152 does not have any formally required prerequisites: An introductory programming class, (such as CS-105 ), significant high school programming experience either from a class or club, and self-taught programming experience can be sufficient preparation for CS-152.

The primary emphasis of this course is to develop fluency in working with conditional control flow, looping structures, and procedural programming techniques. The secondary emphasis is to apply those skills in solving computational problems.

CS-152 is a project based course: students spend many hours writing programs that for a wide range of applications. In past semesters these have included business applications, multimedia manipulations, video games, simulations of complex systems, and scientific models.

CS-152 is currently taught using the Java programming language in the Eclipse Integrated Development Environment.

While Java is an Object Oriented Programming (OOP) language and while students in CS-152 will certainly be working with Objects, CS-152 is not a course on OOP. Experienced programmers with solid skills in control flow, procedural programming and computational problem solving should skip CS-152 and take CS-251 (Intermediate Programming). CS-251 is also currently taught in Java and its primary emphasis is on unerstanding, developing and applying OOP skills.


Syllabus & Lab Schedule

Textbook and Required Materials:
i-clickerŪ. Available UNM bookstore. Register your i-clidker in Blackboard Learn

Introduction to Java Programming, Brief Version (11th Edition) by Y. Daniel Liang
JavaDoc for All standard Java Classes


Lecture Notes and Labs:

Week 1:

  1. Notes: Welcome to CS-152
  2. Notes: Hello World: Intro to Intellij IDE
  3. lab: Lab 1: Change Maker

Week 2 & 3:

  1. Notes: Chapters 1 & 2: Variables, Primitive Numeric Types, Expressions and Assignment Statements
  2. Notes: Chapter 3: Conditional control flow using if, else if and else Stetements
  3. lab: Lab 2: Subtraction Quiz
  4. Notes: Math for Inside and Outside a Circle and Rectangle
  5. Code: InsideOutside.java Solution developed in class for book questions 3.22 and 3.23: Is the user input point inside or outside a particular circle and particular rectangle?
  6. lab: Lab 3: Inside or Outside

Week 4:

  1. Notes: Chapter 4: Java's String Class
  2. lab: Lab 4: Sort Three Cities
  3. Code: CityName.java Program developed in class that inputs a city and country on a single line. The program then uses the substring function to separate the city name from the country name.

Week 5:

  1. Code: JavafxRandomBox.java This is the program we started to develop in class on Monday (Sept. 18). It extends javafx.application.Application and when run, it creates a window into which it draws an endless stream of random rectangles. NOTE: this program requires Java 1.8.
  2. Code: JavafxRandomCity.java
  3. Code: JavafxBall.java
  4. Code: JavafxLines.java
  5. Code: JavafxLines2.java
  6. Code: JavafxSpiral.java Draws a spiral, one line every 0.5 seconds.

Week 6 & 7:

  1. Code: JavafxRandomWalk.java
  2. Code: JavafxTriangle.java Program that draws a Sierpinski Triangle, one point per frame
  3. Code: JavafxTriangle2.java Draws a Sierpinskiu Triangle 1000 times faster than JavafxTriangle.java. This is done by using a for loop.
  4. Code: JavafxPolarEquations.java Draws a Polar Equation that random walks in color and size from full frame down to 20x20.
  5. Code: JavafxBunchOfBalls.java This program takes JavafxBall.java and uses arrays to make 200 bouncing balls. They all bounce off the walls, but pass through each other. This is an example of using arrays.
  6. lab: Lab 6: Particle Effects
  7. Notes: While Loops
  8. Lynda Login: https://lynda.unm.edu/ Login before trying to use the video links below
  9. Video: Lynda Video: Java IDE:Overview
  10. Video: Lynda Video: What is an IDE?
  11. Video: Lynda Video: IntelliJ IDE
  12. Video: Lynda Video: History of Java
  13. Video: Lynda Video: Define Actions Using Code
  14. Video: Lynda Video: Repeat Actions and Test for Conditions
  15. Code: JavafxBunchOfBallsWithCollision.java This is a modification of the Bunch Of Balls code above that includes collision
  16. Code: JavafxWalkAndTurn.java This is a modification of the Bunch Of Balls code where each block has a "friend" which it follows.
  17. Code: JavafxWalkAndTurnWIthTracks.javaWalk and Turn with many more blocks all 1x1.

Week 8 & 9:(midterm exam)

  1. Code: Dog.java
  2. Notes: For Loops
  3. Notes: Class and Method Definitions

Week 10

  1. Code: DeckOfCards.java This is a slight mod of listing 7.2 from the textbook. This conforms to the CS-152 coding standard. It also moves the arrays deck[], SUITS[] and RANKS[] out of main() and makes them class fields. This is useful for expanding the program, as is required in the lab.
  2. Code: DeckOfCardsUNICODE.java This is just for fun. One student asked me how she could display colors and special characters in the console. If you want, you may use this in your lab, but it is not required.
  3. Code: DeckOfCardsJavafx.java This is also just for fun. This example uses extended, multi-word UNICODE and JavaFX to display very special characters for each card in the deck.
  4. Code: DeckOfCardsCompare.java Back to the requirements, this is the example developed in class on Friday Oct 27 in answer to student questions. This includes the 4 of a kind calculation by using a series of helper functions.

Week 11 & 12

  1. Code: DrawStringCommands.java Code we developed in class with a few extras. This is a good starting point for your project.
  2. Code: DrawStringCommands2.java This is almost the same as the first version, but in class we added code to public void handle(ActionEvent event) that removes all white space and splits the rules String into an array of Strings.
  3. Code: DrawStringCommands3.java This example, developed in class, places both the textfield its label on the same line by placing each into an HBox, then adding the new HBox to the Vbox in place the text field and its label.
  4. Lab: Generating and Rendering Lindenmayer System Fractals

Week 13

  1. Code: Javafx3D_block.java Simple example of 3D JavaFX with a few balls and blocks that are all placed in a single Group (called world). The group is continuously rotated (0.25 degrees per 1/60th of a second) around the y-axis.

Week 14 & 15

  1. Code: LSystem0.java Code that shows input fields with default values for both the Axiom, Rules and Generations.
  2. Code: LSystem1.java Solution to part 1.
  3. Code: JavafxDLA.java Example showing *many* particles in a random walk froming a crystal by Diffusion Limited Aggregation.



Past Exams:
  1. Midterm Exam from Spring 2013
  2. Final Exam from Fall 2012