Cmpt 145 winter 2016-17 principles of computer science


Principles of Computer Science Assignment-

Background

In this assignment, you'll be working with two related but distinct problem domains. Read this material carefully.

Question 1 -

Purpose: To build a program and test it, starting with a design document. To get warmed up with Python, in case you are using it for the first time. To establish the standards of documentation and testing for CMPT 145.

Degree of Difficulty: Moderate. Don't leave this to the last minute.

In this question you will implement a program that does the following:

  • It asks the user for a sequence of 9 numbers. The order of the numbers is important, as the rows of the grid use this order.
  • It checks whether the sequence of numbers is a magic square or not. Your program should display the message "yes" if it's magic, or "no" if it's not.

It's very important to point out that you are not being asked to construct a magic square; only to check if a square is magic or not.

We've given you a design document called MagicSquareDD.txt (available on Moodle), which is the result of a fairly careful design process. It describes a collection of algorithms which, when used together, should solve the problem. You must implement the program according to the design in this document. There will be some very small decisions you still have to make about the implementation. Every "Algorithm" in the design document will be a procedure or function written in Python. Function names should be very strongly similar to the given design, if not identical.

It's a top-down design, and algorithms are presented in the order they were designed. In a top-down document, it is common for a function to be called before the algorithm is given; this is the opposite of the order that Python uses. You should not implement the program "top-down." A good rule of thumb is this: "Design top-down. Implement bottom-up." It's not a hard and fast rule, but it's a good guide.

For every function in the program, you are to write testing for it. Your approach should be as follows, for each function you implement:

1. Read the design specification for the function.

2. Write a trivial Python function that does nothing, but has the correct name, the appropriate parameters, and a return value that's appropriate.

The function has the right parameters, and returns a value of the right kind, but doesn't really do what it is supposed to do, yet. Your function could also return None, or some other value.

3. Design a number of test cases for the function based on the information in the design document. Yes, do that before you implement the function! Implement the test cases in a Python file named a1q1_testing.py.

4. Run your test program. Some, if not all, of the tests should fail, because you haven't implemented the function yet. That's exactly where you want to be.

5. Implement the function carefully. Then run the test program. Debug this function as necessary until all the tests pass.

6. If you taken the time to design your tests carefully, you can go on to the next function assured that your implementation of the current function is completely correct. Do not disable the testing of any function. Every test for every function you've written should be tried every time you add a new function.

That way you know if you changed something for the worse.

Because everyone is starting with the same design document, every program will have a high degree of similarity. The value of this assignment is the experience you gain from doing it. Hopefully, you will agree that a good design makes implementation fairly easy. Hopefully, you will see the earmarks of a thorough (if not high quality) design.

Question 2 -

Purpose: To reflect on the work of programming for Question 1.

Degree of Difficulty: Easy.

Answer the following questions about your experience implementing the program in Question 1. You may use point form, and informal language. Just comment on your perceptions; you do not have to give really deep answers. Be brief. These are not deep questions; a couple of sentences or so ought to do it.

1. Comment on your program's correctness. How confident are you that your program (or the functions that you completed) is correct? What new information (in addition to your current level of testing) would raise your confidence? How likely is it that your program might be incorrect in a way you do not currently recognize?

2. Comment on your program's efficiency. How confident are you that your program is reasonably efficient? What facts or concepts did you use to estimate or quantify your program's efficiency?

3. Comment on your program's adaptability. For example, what if Assignment 2 asked you to write a program to check whether a 5 x 5 square was magic (bigger square with a larger sum, using the numbers 1 through 25)? How hard would it be to take your work in A1Q1, and revise it to handle squares of any size?

4. Comment on your program's robustness. Can you identify places where your program might behave badly, even though you've done your best to make it correct? You do not have to fix anything you mention here; it's just good to be aware.

5. How much time did you spend completing this assignment? If you had to solve this problem without the given design document, how much longer (or shorter) do you think it would have taken you to complete, start to finish? Would you have been as con dent in your program's correctness?

Question 3 -

Purpose: To build a program and test it, starting without a design document. This is an exercise to contrast with Question 1.

Degree of Difficulty: Moderate. Don't leave this to the last minute.

In this question you will implement a program that checks whether a N x N square of numbers is a Latin Square or not (see the Background section for the definition). Your program should work by reading input from the console, and sending an answer to the console, as in the following example:

  • It reads a number N on a line by itself. This will be the order of a Latin square. The order must be a positive integer, e.g., N > 0.
  • It reads N lines of N of numbers, i.e., it reads console input for a square of numbers.
  • It checks whether the sequence of numbers is a Latin square or not. Your program should display the message "yes" if it satisfies the above criteria, or "no" if it does not.

Question 4 -

Purpose: To reflect on the work of programming for Question 3.

Degree of Difficulty: Easy.

Answer the following questions about your experience implementing the program in Question 3. You may use point form, and informal language. Just comment on your perceptions; you do not have to give really deep answers. Be brief. These are not deep questions; a couple of sentences or so ought to do it.

1. Comment on your program's correctness. How confident are you that your program (or the functions that you completed) is correct?

2. Comment on your program's efficiency. How confident are you that your program is reasonably efficient?

3. Comment on your program's reusability. For example, did you re-use any code from a different project (maybe Q1)? How easy would it be to re-use any part of your program for another task?

4. Comment on your program's robustness. Can you identify places where your program might behave badly, even though you've done your best to make it correct? You do not have to fix anything you mention here.

5. How much time did you spend completing this question? Compare the time you spent on Q3 with the time you spent on Q1.

Attachment:- Assignment Files.rar

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Cmpt 145 winter 2016-17 principles of computer science
Reference No:- TGS02353890

Expected delivery within 24 Hours