This assignment will make you familiar with unit testing, and with object-oriented
programming in Python 2.6.
The grading scheme is as follows:
Upload all source and result files to WebCT and provide links to all
of them from your index.html file.
Your source code should consist of three distinct modules: Task1.py, Task2.py,
and Task3.py.
Suppose you have to design an spreadsheet application. Your team is assigned to develop a utility library that will be used in the project. Your first task is to implement a class named ColumnNameConversionUtility which provides conversion of column names to integers and vice-versa.
def columnNameToColumnNumber(self, columnName): """ Transform strings used as cell column names (e.g., "A" in the cell reference "A5") to integers (for efficiency reasons). Requirements: - "A" is converted to 0 - "Z" is converted to 25 - "AA" follows "Z" and is converted to 26, and so on - only strings in the range "A" to "ZZZZ" are accepted - column names should be upper case - in case of an improper columnName input, the InvalidColumnName exception should be raised """ def columnNumberToColumnName(self, columnNumber): """ Requirements: - inverse of columnNameToColumnNumber - only integer numbers in the range 0 .. columnNameToColumnNumber("ZZZZ") are allowed as input - output must be upper case strings: in case of an improper columnNumber input, the InvalidColumnNumber exception should be raised """
Suppose you have to develop a tool that allows you to simulate the movement of masses in a 2D environment. For your second task, you will be working on the core classes of the simulator, namely, the point, vector, force and mass classes. You can download the Point, Vector, Force and Mass classes here.
ArithmeticError
exception.
You will need to add those checks and test for them.dotProduct, crossProduct,
normalize
. Also, implement the equals
function in the Force
and Mass classes. You can use the unit tests from question 1 to help you implement
these functions (as done in XP).
Correction: as the cross product of 2 vectors does not exist
in 2D, then you cannot actually compute it. You can either throw an exception (if the
input vectors do not have sufficient dimensions) or not implement it at all. In any case,
it will not be counted in the grading.
Suppose you are to design a ticket distributor for the metro of Montreal. In the
software development process, the use case for purchasing tickets PurchaseTicket
is already written and accepted by the client (the STM?). It describes a "normal"
interaction between a Passenger
and the Distibutor
:
Use case name PurchaseTicket Entry condition The Passenger is standing in front of the ticket distributor. The Passenger has sufficient money to purchase a ticket.
Flow of events 1. Passenger selects a number of zones to be traveled. If he presses multiple zone buttons, only the last button pressed is considered by the Distributor. 2. The Distributor displays the amount due. 3. The Passenger inserts money. 4. If the Passenger selects a new zone before inserting sufficient money, the Distributor returns all coins and bills already inserted. 5. If Passenger inserted more money than the amount due, the Distributor returns excess change. 6. The Distributor issues the ticket. 7. The Passenger picks up the change and the ticket.
Exit condition The Passenger has picked up the selected ticket.
Distibutor
are likely to fail.