Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. Assignment 4 (100 points)
  2.  
  3. Introduction
  4.  
  5. This assignment helps you develop an understanding of how the primary object-oriented features — classes, inheritance, and polymorphism — of languages like C++ and Java are implemented. It will also provide you with some exposure to C++ at two levels of abstraction: the object-oriented level of classes and objects, and the lower-level abstractions of structures and function pointers.
  6.  
  7. You will be given a program written in an object-oriented style in C++, and will be asked to re-implement it, without design changes, using the lower-level abstractions. The goal is not to write it to be simpler, clearer, or more efficient; the goal is to directly implement the provided object-oriented program in terms of underlying abstractions.
  8.  
  9. Understanding the original example
  10.  
  11. You'll be writing code that emulates the object-oriented features (classes, inheritance, and polymorphism) that are normally provided automatically by C++. Your program will be a re-implementation of an original C++ example (OOPorig) that's implemented using object-oriented features. Before you can write your program, you should spend some time reading and understanding the example, since that's the code you'll be emulating. The code has been commented for those of you having little or no experience with C++. With this and help you may get from lab sessions, you should be able to adapt quickly. We're glad to help during lab sessions and office hours. To keep things relatively straightforward, I haven't used any C++ features that don't have an analogue in Java.
  12.  
  13. Because of the way the code is written and commented, it's wise to read and understand it in the following order. Comments in the later files in this list assume that you've read and understood the comments and code in the previous ones.
  14.  
  15. main.cpp
  16. Shape.h
  17. Shape.cpp
  18. Circle.h
  19. Circle.cpp
  20. Rectangle.h
  21. Rectangle.cpp
  22. Square.h
  23. Square.cpp
  24. RightTriangle.h
  25. RightTriangle.cpp
  26. I suggest adding some additional code to the main() function in this example, just to be sure that you understand how the provided example behaves. This will also help you to ensure that you know how to create objects and use the object-oriented features of C++, which may well prove to be handy knowledge to have.
  27.  
  28. Re-implementing the example without OOP features
  29.  
  30. Your main task for this assignment is to re-implement the OOPorig example in C++, without using classes, inheritance, or polymorphism. Instead, you'll be implementing lower-level code that handles the various details, such as virtual method binding. I've provided a starting point called OOPemu that you're required to use. Given to you is part of the main() function, as well as an emulation of the Shape class (heavily commented) and part of an emulation of the Circle class. Since the provided code for OOPemu is heavily commented, it should be clear what's been given and what you'll need to add. You'll need to complete the Circle class, as well as implement the Rectangle, Square, and RightTriangle classes. Additionally, you're required to add code to your main() function that creates various kinds of shapes and demonstrates that your emulation of inheritance and polymorphism are working correctly, at least by calling each method on each kind of object using dynamic binding (by looking up the method in the virtual method table).
  31.  
  32. The logistics of using C++ for this assignment
  33.  
  34. Both OOPorig and OOPemu are provided as Visual Studio 2017 solutions. All of the code that I've written is standard C++, so it should work just as well on other platforms and using other (standards-compliant) compilers as it does with Visual Studio 2017. Still, it's important to note that C++ implementations can vary in some pretty fundamental ways, so we'll require that your code compiles and executes correctly using Visual Studio 2017. Even if you choose to use something else for your work, verify that your program works with Visual Studio 2017 before submitting it. (The free Visual Studio 2017 Community Version is enough for this assignment.)
  35.  
  36. Deliverables
  37.  
  38. You need to submit all of the source and header files, including those provided, that comprise OOPemu. Please submit only your source code (.cpp and .h files) — do not submit compiled versions of your program, or other files generated by your development environment (e.g the files in “Debug” folder). Also, do not under any circumstances submit the code from OOPorig; that's provided to you for reference, but will confuse us in the grading process. Put all files of your Visual Studio 2017 solution into a single zip file, and upload this zip file to the submission link for assignment 4 in Canvas before deadline.
  39.  
  40. If you work in a group of two, please let only one group member upload the submission. Both group members' names and IDs should also be in a text file called names.txt included in the zip file.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement