CSCI251 Advanced Programming

Assignment Help on Laboratory Exercises

In these series of laboratory exercises you will be learning and practicing various programming concepts enabled by C++ programming language. Mostly, these concepts will be introduced through simple and sometimes complex examples. You are encouraged to think about how and why things work the way they do. The exercises are not set up to trip you.

In order to focus on the task at hand, you can use an integrated development environment (IDE) to write, compile and test your code. In one of the notes provided on Moodle, you can find the steps required to install Code::Blocks on several OS (e.g. Windows, Linux, MacOS). You are encouraged to follow the instructions and install it for your operating system. The operating system on which you develop your code should not matter. All that needs to happen is that your code is C++17-compliant. The system on which your code will be tested has g++

7.5 installed and your code must work on that system (i.e. capa.its.uow.edu.au).

In order to test that your code is compliant and will work on capa.its.uow.edu.au, you will need to do a secure login to capa and test your code. The appropriate option required to ensure that you are compiling against C++17 is the -std=c++17 added to your command line instruction. For example:

g++ file1.cpp  file2.cpp  file3.cpp  -Wall  -std=c++17  -o  output_exec

If your code does not compile, the maximum mark you can get is 50% of the marks allocated to the  exercise.  We  will  not  debug  your  code.  Get familiar with your IDE and ensure that the build option is set to use c++17 and turn warning ON with -Wall option.

Use sensible names for your variables and insert comments to let the reader know what your code is doing. If your code contains no comments you will lose marks.

Get Your Customize Task on any subject starting 10$/Page

Code submission

For each exercise, name your code as instructed. Each Lab will be due for submission at midnight on Friday of Weeks 3, 5, 7, 9 and 11. You will also be reminded accordingly as the session progresses.

Use the zip archiving tool to pack your codes together and name the zip file your login Lab#.zip; The symbol # represent the lab number. Name your source codes as instructed in each exercise. Place multiple source files required for a give exercise into a folder before archiving all your files. Do not submit project files; only source code files (i.e. .cpp and .hpp).

Task One: Debugging

  1. Buggy inheritance: Fix Debug-A.cpp.   The execution of this program, with input as shown (Blob ), should be:

Enter painting's title Blob Enter artist Degas

Enter painting's title Blob Enter artist Alice

Enter painting's title Blob Enter artist Bob

Enter painting's title Blob Enter artist Picasso

Blob by Degas value $25000 Blob by Alice value  $400 Blob by Bob value $400

Blob by  Picasso  value  $25000

  1. Why will the following fail to compile?

class  B

{

public:

virtual void  X()  =  0;

};

class D : B

{

public:

virtual void X() {std::cout << "D object" << std::endl;}

};

int main()

{

B objB;

}

Task Two: Relationships

  1. A Box in a Box in a Box: Write code in Box.cpp to represent storing a collection of Boxes, i.e. Box objects, within a Box object. You will need functionality to add a Box to a Box. You can play around with this idea a fair bit, and potentially include limits on the number of Boxes or the size and capacity of Boxes to make sure that a Box cannot be added to
  2. Consider A-Class.cpp.
    • What concept does it illustrate?
    • How are the classes related?
    • What happens if either the worker or company is deleted in main, after the Contract is set up but before the output is displayed?
    • What happens if we add an additional company and add a contract between John and the new company? How would we manage this situation, or the case where a new worker wants to work for Bell?

Task Three: Inheritance, abstraction, and polymorphism

  1. An Animal hierarchy:
    • Modify the provided Cat class so it is derived from a base class Animal. Write the base class Animal. Make another subclass of Animal and make sure there is some functionality distinguishing them. Write a main function to illustrate creating instances of all three
    • Make the base class Animal abstract, and modify the derived classes if necessary to make sure they are not abstract The Animal instance can be commented out in main for the version you submit.
    • Write driver code containing a vector of pointers to Animal in which you store multiple different types within the Animal hierarchy, and demonstrate adding different types of Animal to this
  2. Transportation hierarchy : For each of the classes below you should provide sufficient functionality to test your understanding of the relationships between the classes. You should, in particular, see how you can use constructors across The code should be able to compile but you don’t need to store data or have other data within each class at this point.
    • Define a base class
    • Define three derived classes, SeaTransport, LandTransport, and
    • Inheritance can occur across multiple Define Car and Canoe as classes derived from appropriate classes.
    • It is possible to have multiple inheritance in C++. Define Hovercraft as derived from two appropriate
  3. This involves extending the Transportation hierarchy set up
    • Now add some data elements and member functions to support the
    • Make Transportation an abstract class by adding an appropriate display()
    • Make a collection that could contain various different forms of Set different elements of the collection to refer to a range of different forms of transport.
    • You can add in additional types of transport if you
    • Illustrate the polymorphism present in the use of the display()
    • What is the diamond Explore how you deal with that problem in the context of the HoverCraft?

Task Four: Libraries

This section is quite methodical but it is important to know how to do this because you will need to use a provided library in Assignment 3 (A3).

  1. The files cpp, mylibrary.cpp, and mylibrary.h form a program.
    • Produce an executable from those

g++  -std=c++17  driver.cpp  mylibrary.cpp  -o  M1

  • Convert the non–driver cpp file into a static library libcode.a. g++ -std=c++17 -c cpp

ar  -crv  libcode.a  mylibrary.o

  • Generate an

g++ -std=c++17  driver.cpp  libcode.a  -o  M2

  • Convert the non—driver cpp file into a shared (dynamically linked)

LD_LIBRARY_PATH=.

export LD_LIBRARY_PATH

g++ -std=c++17 -fpic -shared -o libcode.so mylibrary.cpp

  • Generate an

g++ -std=c++17 -I. -L. driver.cpp -lcode -o M3

  1. How do the 3 executables differ in size?
  2. Which of the 3 executables run without the corresponding library being present?
  3. Using a prebuilt static libary: The file mash.h is the header file associated with the static library in libmash.a. Write a program mainMash.cpp that includes the header to access the function
    • In your main() you should apply mash to each command line argument, including the Note that you can an convert argv[i] to a string by initialising a string with the C–string as an argument, so using

string temp(argv[i]);

  • As per the instructions in the lecture notes you can compile to link the library in using the following:

g++ -std=c++17 mainMash.cpp libmash.a -o Mash

  • What does mash appear to do?
    1. What happens if you feed the input back in? Consider feeding 83 in, then the output, then the output, ...
    2. How is the pigeon-hole principle relevant?

Task Five: The Three Little Software Engineers

Carry out these tasks for The Three Little Pigs, a story in 3Pigs.txt. Ideally you should be discussing this with other people.

  1. Write a timeline identifying the events in the
  2. Identify appropriate objects/classes and attributes/behaviours for those
  3. Sketch a class diagram showing the classes and appropriate relationships. This may be a somewhat iterative process with multiple
  4. Write code to implement the identified
  5. Write main() function(s) which when run will approximate the events of the story, or similar It can be interactive if you like, to cover variations on the stories.

Breathe a Sign of Relief with our Academic Assistance: Get instant help, 100% personalized and accurate solutions that make your study life better.

Expert's Answer

Your future, our responsibilty submit your task on time.

Order Now

Need Urgent Academic Assistance?

Get Professional Help at Low Prices!

*
*
*


*

TOP
Order Notification

[variable_1] from [variable_2] has just ordered [variable_3] Assignment [amount] minutes ago.