Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MTRX3760 - Lab 2

Inheritance and Polymorphism

This assignment contributes 5% towards your final mark. It is to be completed individually, not in groups. Total Marks: 100.

This assignment is due before the start of your allocated lab session in two weeks, i.e. before the

start of the Week 4 lab session for Thurs/Fri labs, and before the start of the Week 5 lab session for Monday labs. Late assignments will be subjected to the University’s late submission policy unless accompanied by a valid special consideration form. Plagiarism will be dealt within accordance with the   University of Sydney plagiarism policy. Lab submissions will not be accepted more than a week after the due date.

Assignments will be assessed based on the following components. Incomplete submissions will have severely reduced marks:

●   Report: Submit a .pdf report using the class Canvas site. The report can be very simple, and needs only directly address the questions laid out in the assignment.

The cover page for your report should include your SID and tutorial section, but do not include your name to comply with the University’s anonymous marking policy.

Code appendix: The appendix of your report must contain a printout (in text format) of all source code written for the assignment. File header comments and proper formatting will be  critical to making this section readable. Unintelligible code attachments will result in loss of marks.

   Code: Submit your code (code only, no binaries) in a .zip file via the canvas site.

Please see Lab 1 for hints on preparing your report, including how to format code for inclusion in the appendix.

Polymorphic Combinatorial Logic Simulator

This lab can be completed with concepts taught in lectures from Weeks 1 and 2.

The logic simulator from Lab 1 was limited to simulating NAND gates. In this example you will apply    your knowledge of inheritance and polymorphism to redesign that program. You may start from the code you produced in Lab 1, or redo the program from scratch.

For this assignment all code should follow the coding practices and concepts covered in the Week 1 and 2 lectures, including coding style and use of constructors / destructors.

Make the following changes to the program:

A.  Add the capability to simulate AND, OR, and XOR gates.

B.  Add the capability to instantiate and simulate sub-circuits. A half adder and a full adder are examples of sub-circuits.

C.   Simulate an adder that accepts two 3-bit binary inputs, and outputs their sum. Your adder should be constructed from half adders and full adders.

Hints / Simplifications:

●   As in Lab 1 it is acceptable for circuit construction to be hard-coded, but think carefully about where this occurs.

   As in Lab 1 you do not need to split the program (source code) into multiple files.

●   Work incrementally. Proceed through the steps A-C above one at a time, testing your program at each stage. Do give some thought, in Step A, how you might achieve Step C.

●   Refer back to the checklist provided with Lab 1. Included below is a coding style guideline based on best practices described in lecture.

[20 Marks] Functionality: In your report show the output of your program demonstrating correct

operation of the adder. Think about how you will test your circuit and demonstrate that it is working   correctly. Program output should be copy/pasted into your report, not displayed as a screenshot. Your report and the code in your attached .zip file will be assessed for correct functionality.

[30 Marks] Code Quality: Your code will be assessed based on style and coding best practices as taught in lecture.

[50 Marks] Design: In your report provide a complete UML class diagram for your design, including significant member variables and functions. This diagram and your code will be assessed based on     appropriate use of the design principles taught in lecture.

Self-Assessment

[+5 Bonus] In your report estimate the level of achievement of your submission. Show estimates for all component grades as well as the total. If your estimated total is within 5 marks of the correct score you will be awarded 5 bonus marks. Ignore late penalties when estimating.

/20 Functionality

/30 Code quality

/50 Design

/ 100 Total

Coding Style Guideline

This is a summary of specific advice given in lectures, but be mindful that you are making many more   decisions than these about how to write your code, e.g. how you choose to name your variables, in what case, etc. Throughout the lectures we have emphasised consistency: the code you submit should use the same style throughout.

Lec 1B

1.   Informative naming

2.   Consistent, defensive bracing; one statement per line

3.   Consistent indentation, spacing, bracing

4.   Readable variable declarations, one variable per line

5.   Avoid #defines, they hide bugs well; use consts instead

6.   Shape comments & whitespace to highlight structure

Lec 2A, 2B

1.   Emphasise parallel structures to help spot bugs

2.   Avoid repeating code: fewer bugs, less code to maintain

3.   Avoid multiple exits, these make it harder to debug with breakpoints, couts