代做CISP 400、代写Programming Test、代做CS/python, C/C++编程代做数据库SQL|代做Processin

CISP 400 – Final Exam – Programming TestDue December 20, 2018 at 11:59 PMNO CHANGES TO THIS DUE DATE WILL BE MADEPlease answer the following questions in a single PLAIN TEXT file (e.g. not HTML, not wordprocessing, etc. Windows Notepad can be used if you are unsure, as can most IDEs that you have usedfor programming in this class). Questions 1 and 2 are independent of all other questions. Questions 3-5 build upon one another, although each question can be answered without fully or correctly answeringthe others if you are having difficulty with an earlier question. Each question is worth 8 points, for atotal of 40 points (50% of the exam).As with the first part of the exam, it is open-book and open-note but should not be discussed or donewith any other person. Group work or obtaining help of any kind from another individual will beconsidered cheating.1. Write a template function. The template should accept one type parameter, type T. The functionitself should return type T, and accept THREE parameters – an array of type T named source, a singleinstance of type T named initial, and an int that is the length of the array named length. The functionshould have a local variable of type T, named total, which is initialized to the value provided by initial.The function should loop over the array to use the + operator to combine all array elements into total. Itshould then return total variable. In other words, if it is passed an array of type double, then it will addup all the elements in the array. If it is fed an array of string type, it will concatenate all of the stringsin the array (that is to say, combine them, one after another). NOTE: We are looking for an ordinaryarray for this question. Do not use the STL array type.2. For this question, we will be using the ErrorData class. We aren’t writing it, just using it in ourcode. All you need to know about it is that it will work with the the user using cout. Its constructor takes no parameters, and neither the constructor nor destructor doesanything that you need to worry about (or for that matter, anything at all).Suppose we are writing a function, attemptErrorProneOperation(). attemptErrorProneOperation()rerturns nothing and takes no parameters. Normally the only thing attemptErrorProneOperation() doesis it calls another function, possibleError(). You do not need to know anything about possibleError()other than it may throw an exception. In addition to calling possibleError(),attemptErrorProneOperation() catches exceptions thrown by its call to possibleError(). Any exceptionsthrown by possibleError() will be either a variable of type int, or an object that is an instance of theErrorData class. Any exception data caught should be printed to the user using cout.attemptErrorProneOperation() will then exit, whether or not an exception has been caught.Write the attemptErrorProneOperation() function so that it makes the call to possibleError() andhandles both types of exception that possibleError() may throw. Remember that there is a specific waythat you should catch objects that we have discussed, so be sure to use that.3. Write an abstract class. The class will be named ShapeCalc. It will define the following members: two double 代做CISP 400作业、代写Programming Test作业、代做CS/python, C/C++编程作业 代做数type variables named a and b, both set with access so that subclasses may accessthem directly but the outside world cannot. a getter and setter for a and b, each, so you have getA(), getB(), setA() and setB(), eachreturning the appropriate data types and taking the appropriate parameters. a pure virtual function, calculation, that takes a parameter of type bool, and returns a value oftype double. a virtual destructor that does nothing (empty body). If you wish, for debugging purposes it mayprint a single message to the screen informing the user that it is being destroyed, but that isstrictly optional. The code for this function may be inline (part of the class declaration) oroutside of the declaration, but a body must be provided.You may write the code to work in either the class declaration or outside of the class declaration, but allcode must CLEARLY be coded as a member of the class, e.g. dont make any of these non-classfunctions.A constructor is not necessary, but can be included if you wish.4. Assume that you have written ShapeCalc correctly.We are now writing two subclasses of ShapeCalc: HypCalc and CylCalc. Note that each should inheritShapeCalc for public access.Both of these have only one member function, which overrides the calculation() virtual function.For CylCalc, you must take the member variables and use them to calculate the volume of a cylinder,specifically V = πr2h. As per usual in equations, π can be assumed to equal 3.14, but you can use amore precise constant if you would prefer. r will be a, and h will be b. So: (3.14) * (a * a* b). Thefunction will then look at its only parameter, which is of type bool. If it is true, then the calculatedvalue will be multiplied by 2 and then returned; if false, it will be returned as it was originallycalculated.For HypCalc, we are going to calculate the hypotenuse of a right triangle, which is:h=√(a2+b2)with h being the hypotenuse length. Use the mathematical library functions pow() and sqrt() tocalculate this value. The function will then look at its only parameter, which is of type bool. If it istrue, then the calculated value will be multiplied by 2 and returned; if false, it will be returned asoriginally calculated.5. Assume that you wrote ShapeCalc and at least one of its subclasses (HypCalc or CylCalc) correctly.Make a non-member function named compute(), which takes in two double arguments and returns novalue. It will need two local variables – a shared pointer of type ShapeCalc named crunch (as in,crunching the numbers), and a double named result.First, crunch will be set to a shared pointer to hold an object of either type HypCalc or CylCalc (yourchoice, the code should be identical for both outside of the class name). This object will need to beconstructed within the function.crunch will use the setters to provide the values 2 and 4 to the a and b variables of crunch, using theShapeCalc setter functions.The calculation() member function on crunch will then be executed, and the value will be stored inresult.The value in result will then be printed to cout, followed by an endline.Finally the function will clean up after itself (if need be, remember, you might not need to doanything!) and the function will return.转自:http://ass.3daixie.com/2018122139915461.html

你可能感兴趣的:(代做CISP 400、代写Programming Test、代做CS/python, C/C++编程代做数据库SQL|代做Processin)