Category Archives: Resources

OOD – Colliding Balls Simulation

Follow these steps:

  1. Download the attached BlueJ project file, Collision.zip to your java folder. Double click on it.
  2. Open the folder and double-click the BlueJ package icon.
  3. Replace “_YI” suffix with your initials in all the files that use it.
  4. Study the code for the Ball_YI, BallDriver_YI, and CollidingBall_YI classes.
  5. Modify the Ball_YI class as follows:
    — a. When any ball collides with another, the ball changes direction. Their behavior after the collision is up to you but it has to be noticeable. There are two types of collisions, elastic and inelastic. It is also up to you to choose the type.
    — b. When any ball collides with each other, the ball changes to a random color and stays that color until it collides again.
    — c. When any ball collides with the walls, the ball changes to a random color. NOTE: It is ok if all the balls change color at the same time.

    Submission:
  6. A short QuickTime video.
  7. Attach Ball_YI, and CollidingBall_YI classes.

Collision Detection:

 These diagram should help you with the calculations for the conditions you need to implement to capture the the balls within a “d” distance of each other:

   or

More Hints: look at the problem from the cartessian plane perspective:

OOD: BallDriver and CollidingBalls Videos

BallDriver Video #1
A short video for Ball and BallDriver – Looking at the geometry behind the relative distance between 2 balls.
Oops: I meant radius.

BallDriver Video #2
Going over the first changes we did to the original code.

BallDriver Video #3
Integrating the geometry into the implementation to have a better way to determine the distance apart from a pair of balls.

BallDriver Video #4
Overloading
A quick look at two constructors for the same class.

BallDriver Video #5
Ball ADT and BallDriver Complete
This is the final version of the BallDriver assignment. The important concept to learn is how accessor methods are used to get information from the input argument which is an object of the Ball ADT. This illustrates ENCAPSULATION since instance fields are private and public methods are needed to get access to their values.

BallDriver Video #6
Last video and final implementation (no color)

BallDriver Video #7
Code for color changing of the balls

BallDriver Video #8
Putting color in the BallDriver assignment.

CollidingBalls Video #9
Overloading Trick

How to make a short video of your animations using QuickTime

OOD – My School: Multi – ADT application And More

/**
 * Teacher t1 = new Teacher("Sarah", "Clark", 35, "female", "Hello, class!");
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Teacher
{
    private String firstName;
    private String lastName;
    private String age;
    private String gender;
    private String greeting;
    private Course course;
    private Student aStudent;

    public Teacher(String firstName, String lastName,Course course,Student stu)
    {
        this.firstName = firstName;
        this.lastName = lastName;
        this.course = course;
        aStudent = stu;
    }

    // draw teacher(s)
    public void draw()
    {
        StdDraw.picture(-1,-1.5,"school_teachers.png",2,1);
    }
    
    // getter/accessor methods
    public String getName()
    {
        return firstName+ " " + lastName;
    }

    public String getAge()
    {
        return age;
    }    

    public String getGender()
    {
        return gender;
    }

    public String getGreeting()
    {
        return greeting;
    }

    public String toString()
    {
        String output = "";
        output += "Teacher name: " + firstName + " " + lastName + "\nCourse Taught: " + course + "\nStudent: " + aStudent ;

        return output;
    }
}

/**
 * Cistomized driver to test all the different parts of my class MySchoolTest
 *
 * @RA & mrs.e
 * @1.8 3/13/18 & 5/10/19
 */
public class MySchoolTest
{
    public static void main(String [] args)
    {
        //StdDraw.setXscale(-2.03,2.03);
        //StdDraw.setYscale(-2.03,2.03);
        StdDraw.setXscale(-2,2);
        StdDraw.setYscale(-2,2);
        
        //create an object of student
        //then create 3 objects of course
        //afterwards we add the 3 objects of course to the student 
        Student konoa = new Student("Konoa", "Smith", "15", "female", "1234");  
        konoa.draw();

        Course c1 = new Course("Biology", "5", "102");
        Course c2 = new Course("precalculus", "4", "136");
        Course c3 = new Course("APUSH", "7", "117");

        // create an object of Teacher
        Teacher mrBill = new Teacher("Jasmine", "Flores", "28", "MYOB", "Namaste", c1);
        // print a teacher
        System.out.println("\n" + mrBill);
        mrBill.draw();

        // print a course information
        System.out.println("Print a course ");
        System.out.println(c1);

        // add all courses to an array
        Course [] courses = { c1,c2,c3};

        // assign all courses to a student
        konoa.setCourses(courses);
        c1.draw();
        //print a student info and courses
        System.out.println("\n" + konoa);
        
        /**
        *  I omitted the school object for easier understanding 
        *  of few interacting ADT objects
        */
    }

}

/* 
 * Teacher name: Jasmine Flores
 * Course Taught: 
 * Class name: Biology
 * Room Number: 102
 * Period:  5
 * 
 * Print a course 
 * Class name: Biology
 * Room Number: 102
 * Period:  5

 * Student name: Konoa Smith
 * Courses: 

 * Class name: Biology
 * Room Number: 102
 * Period:  5

 * Class name: precalculus
 * Room Number: 136
 * Period:  4

 * Class name: APUSH
 * Room Number: 117
 * Period:  7

 * 
 */

OOD Project: LFSR

Animations using java
duke

Screen Shot 2015-02-23 at 12.19.21 AM

If you are still trying to fit all the piece together, look again at the transform method from PhotoMagic.java:

The transform() method
Takes a Picture and an LFSR as arguments and returns a new Picture object that is the result of transforming the argument picture using the LFSR as follows:

  1. For each pixel (col, row), in column-major order—(0, 0), (0, 1), (0, 2), … —extract the red, green, and blue components of the color (each component is an integer between 0 and 255).
  2. Then, xor the red component with a newly-generated 8-bit integer.
  3. Do the same for the green (using another new 8-bit integer) and, finally, the blue.
  4. Create a new Color object using the result of the xor operations, and set the pixel in the new picture to that color.

OOD: Dodge Ball Game Videos

Dodge Game Video #1
Project Setup

Dodge Game Video #2
Mouse Follower

Dodge Game Video #3
Simple Weighted Attraction

Dodge Game Video #4
Dodge Game Spring Moti

Dodge Ball video #5
Changing the MouseFollower into an ADT part 1 of 2

Dodge Ball video #6
Changing the MouseFollower into an ADT part 2 of 2

Dodge Ball video #7
Player and CollidingBalls integrated into the driver, DodgeGame (1 of 2)

Dodge Ball video #8
Player and CollidingBalls integrated into the driver, DodgeGame (2 of 2)

How to make a short video of your animations using QuickTime

Cryptography – Resources

Your Cipher – Clwk 9/6/2018 – Cryptography

Due 09/11, 6:45 PM

Instructions

‘3. Design your own cipher and a device to easily encrypt and decrypt messages.

Describe your cipher. Draw a diagram for your device. Build your device. Type here decryption instructions.

    1. Friend’s Cipher – Cryptography

Find a classmate and exchange ciphers, instructions and encrypted message. After you checked with your classmate that you were able to decrypt the message, comment on the following: Efficiency of the cipher Quality of the instructions

NOTE: If the instructions were not clear or you couldn’t follow them, help your classmate make the right changes. Include the name of your classmate.

    1. Brute Force – Cryptography

If you didn’t have a key to decipher an encrypted message, how would write a program to decrypt it?

Write the pseudocode for you decrypting program using brute force.

Submit the instructions for your encryption device in the corresponding post. Include your name in the instructions.

Print your instructions and attach it to your device. I will “glue/attach” it to a poster. Please hand everything with your name on it.

De-Crypt: Caesar Cipher – Clwk 9/6/2018 – Cryptography

Due 09/06, 6:45 PM

Instructions

    1. In this post type your partner’s encrypted message and the one piece of information needed to decrypt it. What is the message?

NOTE: Include your partner’s name

En-Crypt: Caesar Cipher – Clwk 9/6/2018 – Cryptography

Due 09/06, 6:45 PM

Instructions

https://java.mrseliasclasses.org/cryptography-caesar-cipher/

    1. Use the “cipherwheel” to encrypt a message. In a piece of paper, share the encrypted message with a partner. In this post, you will type the message, the encrypted message and the one piece of information needed for your partner to decrypt it.

NOTE: Include your partner’s name Yours should be at the top.

Submit here both messages from you: the encrypted and the decrypted from your partner.

What do you need to tell your partner to be able to decrypt the message?

Encryption and Decryption Hand-written Example

Due 09/11, 6:45 PM

Instructions

Hand-in the paper(s) with your english sentence and the encrypted version for your partner. And, the encrypted sentence from your partner and the english version of it.

Information entropy | Journey into information theory | Computer Science | Khan Academy

https://www.youtube.com/watch?v=2s3aJfRr9gE

Shannon Entropy and Information Gain

https://www.youtube.com/watch?v=9r7FIXEAGvs

https://www.youtube.com/watch?v=9r7FIXEAGvs&t=57s

Entropy in Compression – Computerphile

https://www.youtube.com/watch?v=M5c_RFKVkko

Your Cipher – Clwk 9/6/2018 – Cryptography

Due 09/11, 6:45 PM

Instructions

‘3. Design your own cipher and a device to easily encrypt and decrypt messages.

Describe your cipher. Draw a diagram for your device. Build your device. Type here decryption instructions.

    1. Friend’s Cipher – Cryptography

Find a classmate and exchange ciphers, instructions and encrypted message. After you checked with your classmate that you were able to decrypt the message, comment on the following: Efficiency of the cipher Quality of the instructions

NOTE: If the instructions were not clear or you couldn’t follow them, help your classmate make the right changes. Include the name of your classmate.

    1. Brute Force – Cryptography

If you didn’t have a key to decipher an encrypted message, how would write a program to decrypt it?

Write the pseudocode for you decrypting program using brute force.

Submit the instructions for your encryption device in the corresponding post. Include your name in the instructions.

Print your instructions and attach it to your device. I will “glue/attach” it to a poster. Please hand everything with your name on it.

De-Crypt: Caesar Cipher – Clwk 9/6/2018 – Cryptography

Due 09/06, 6:45 PM

Instructions

    1. In this post type your partner’s encrypted message and the one piece of information needed to decrypt it. What is the message?

NOTE: Include your partner’s name

En-Crypt: Caesar Cipher – Clwk 9/6/2018 – Cryptography

Due 09/06, 6:45 PM

Instructions

https://java.mrseliasclasses.org/cryptography-caesar-cipher/

    1. Use the “cipherwheel” to encrypt a message. In a piece of paper, share the encrypted message with a partner. In this post, you will type the message, the encrypted message and the one piece of information needed for your partner to decrypt it.

NOTE: Include your partner’s name Yours should be at the top.

Submit here both messages from you: the encrypted and the decrypted from your partner.

What do you need to tell your partner to be able to decrypt the message?

Encryption and Decryption Hand-written Example

Due 09/11, 6:45 PM

Instructions

Hand-in the paper(s) with your english sentence and the encrypted version for your partner. And, the encrypted sentence from your partner and the english version of it.

Information entropy | Journey into information theory | Computer Science | Khan Academy

https://www.youtube.com/watch?v=2s3aJfRr9gE

Shannon Entropy and Information Gain

https://www.youtube.com/watch?v=9r7FIXEAGvs

https://www.youtube.com/watch?v=9r7FIXEAGvs&t=57s

Entropy in Compression – Computerphile

https://www.youtube.com/watch?v=M5c_RFKVkko

CS Department: University of Washington

My Old Website

NOTE: This old web site is out of date. This is the course web site from a past quarter, 15wi (Winter 2015), but the current quarter is 19su (Summer 2019). If you are a current student taking the course, this is not your class web site, and you should visit the current class web site instead.

Links

Programming:

For your homeworks:

  • Unofficial style guide, developed by a TA. Style tips are covered chapter by chapter with sections at the end for indentation, spacing, and commenting.

Software:

Computer Science Major:

Other: