# January 28, 2017Python | CIS 211 Project 3: OOP

1/27/2017 planets (1)
CIS 211 Project 3: OOP Due 11:00 P.M. January 27, 2017
Our goal this week is to gain some experience writing class definitions for some simple objects. The classes are part of a solar system simulation. This week we’ll define the objects used in the simulation. Next week we’ll implement the simulation itself, and later in the term we’ll add visualization.
Part 1: Vectors (50 points)
Define a class named Vector. Instances of this class will be Euclidan vectors (https://en.wikipedia.org/wiki/Euclidean_vector (https://en.wikipedia.org/wiki/Euclidean_vector)).
An instance of this class will have three attributes, representing , , and coordinates in space. When a Vector object is created the constructor should be passed three numbers to use as the initial values of the coordinates.
accessor functions named x, y, and z, which return the current value of the specified coordinate
a __repr__ function that displays a Vector as a tuple of 3 numbers; use “%.3g” in the format statement so coordinates are shown with 3
significant digits
methods that implement ==, +, ‐, and * operations (see below)
a method named norm that computes the length, or magnitude, of the vector, defined by the equation
a method named clear that sets all coordinates to 0
To see if two vectors are equal, simply see if their , , and components are the same. This will almost certainly fail (due to roundoff errors) when the coordinates are of the size used in the solar system simulation, but it will help test the other operations, and we’ll use small numbers in these tests.
To add or subtract two vectors, make a new vector that has the sum or difference of the components of two existing vectors.
The method that implemements multiplication should implement scalar multiplication: the second operand should be an integer or a float, and the result is a new vector where all components are multiplied by the scalar.

# January 25, 2017MIPS | CMPUT 229 (Winter 2017) – Homewor

CMPUT 229 (Winter 2017) – Homework #1 Instructor: Karim Ali
Question 1: (5 points)
Consider that a processor architecture ToyProc, which was initially designed as big- endian, is changed to use little-endian byte ordering. Assuming the subset of the MIPS ISA that you are familiar with, and assuming a memory with a word-level interface, give examples of instructions whose operations will be affected by such a change in endianness.
Question 2: (5 points)
Write the C code that best corresponds to the following MIPS assembly code. Assume that registers \$s1, \$s2, and \$s3 store the values of 32-bit integers x, y, and z.
L1: beq \$s1, \$zero, L2
L2:
Question 3: (15 points)
For this question, assume that:
• p, q, i, j are 32-bit integers whose values are stored in \$s0, \$s1, \$s2, and \$s3, respectively.
• A and B are arrays of integers.
• r is a pointer declared as int *r.
• r, the base address of array A, and the base address of array B are all in the stack frame of the current function, as shown below
For each of the C statements below, give the translation into MIPS. Do not use pseudo- instructions in your code. Clearly label which MIPS instructions are for which statement.
a. (5 points) q = *r
b. (5 points) B[i] = A[j]
c. (5 points) p = q + A[B[j]] Question 4: (15 points)
Write the assembly code to implement the following C function:
int selector(int array[], int i) {
return array[array[i]];
}

# January 20, 2017Processing | Excel | Matlab | EXAM – ECE 102

EXAM – ECE 102
Instructor: Peter Jamieson
Directions:
– This is a take home exam. The work must be your own. Any common code will result in the exam being forwarded to administration for academic integrity violation. Do not show, give, or tell anyone else how you are solving the problems.
Details:
– The total for the exam is 100 marks.
– Submit your zip file with the exact details below
ZIP File:
– XYOURUSERNAMEX/XYOURUSERNAMEX.pde a directory and in that directory a processing file for question 2
– MATLAB/ XYOURUSERNAMEX.m a directory called MATLAB with a matlab script for question 3
– ETHICS/ XYOURUSERNAMEX.doc or .txt a directory called ETHICS with a document describing your ethical thoughts

# January 12, 2017MIPS | Algorithm | Minecraft-Texturen

1. An image can be stored in the memory as an array by continuously storing the individual lines with image points one behind the other.
2. At the beginning of the image there is also a header, which contains the width, height and color depth, which is the number of colors.

1.Your program should be able to read and write image files in the PGM format (binary, P5). a) 提示:To read and write files, QtSPIM, similar, or other operating system, provides different syscalls. You must calculate the value of the number from a string of digits.
To do this You need an ASCII table.

# January 10, 2017Processing | COMP115 – Introduction to Computer Programming

Department of Computing
COMP115 – Introduction to Computer Programming Assignment 2
ASSESSMENT DETAILS
Due: 23:45, 17th January, 2017
Worth: 20% (marked out of 100)
Updated: 9th January, 12:45pm. Update 1: added values for S1 and S2 under subtask 1.1. Update 2: corrected weight of assignment (20)
INSTRUCTIONS
In this assignment, you will write a simple particles simulation. A particle is represented by a circle, filled with a random colour and size. Each particle moves at a velocity and bounces when hits with the edges of the simulation screen. The simulator must be able to run on the graphic screen of different size.