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

COMP2404ABC (Winter 22) -“Introduction to Software Engineering”

Practice Midterm Questions

1    Programming

Question 1:

# include   < string >

# define   MAX_ARR   200

using   namespace   std ;

class   Book {

public :

Book ( const   string &  t ,   float  p ):   title ( t ) ,  price ( p ){}

 

const float

private :  string

float

};


string &   getTitle (){   return   title ;}

getPrice (){   return   price ;}

 

title ;

price ;


class   BookStore {

public :

BookStore ( const BookStore ( const ~ BookStore ();


string &  name );

BookStore &);


//  make   a  Book   and   add   it   to   the   back   of   the   array

void   addBook ( const   string &  title ,   float   price );

//   get   the   Book   with   the   title   given

void   getBook ( const   string &  title ,  Book **)   const ;

//   remove   the   Book   with   the   title   given

void   removeBook ( const   string &  title ,  Book **);

//   find   a   return   the   Book   with   minimum   Price

void   getMinPrice ( Book **)   const ;

 

private :

//   the

string


name   of   the   BookStore

name ;


//   an   array

Book **   books ;

//   the   number   of   elements   in   the   array

int   numBooks ;

};


Observe the above class specifications for the BookStore and Book classes.   The Book class is complete as written.  Write the code for BookStore.cc.  The array of Books should have a size of MAX ARR. Make sure you use proper Object Oriented programming techniques, and make sure that all memory that is allocated in the BookStore is deleted.

You should be able to write any of these functions (you may be given the class definition and be asked to write a subset of the functions). You should also be competent at writing similar array traversal questions (getMaxPrice for example, or a function updateAllPrices() that applies a function updatePrice(Book&) to every Book in the array), or functions with small amounts of application logic (such as meetsCriteria from the Room class of Assignment 1). Also be familiar with how to write the above functions using other types of arrays.

 

2    Multiple Choice Practice

These open-ended questions are designed to help you prepare for the multiple choice section.  These questions are not comprehensive. You should be familiar with anything in the notes that we have taken so far.

1.  How would you compile an object file? An executable? How do you link object files into an executable?

2.  How would you code an input parameter? How would you code an output parameter? How would you code a return value?

3. What types of constructors are there and what are their function signatures?

4. What are namespaces and how are they used?

5.  How do you dynamically allocate an object?   How would you statically allocate an object?   What is the difference?

6. When storing classes, what are the 4 types of arrays and how would they be implemented?

7. What are the object categories and what are their purposes?

8. What type of information is shown in a UML diagram? What type of information is not shown?

9. What is encapsulation? What is the principle of least privilege? What are their purposes?

10. What is member initializer syntax and where should it be used?

11. In what ways can you use the const keyword, and what is the purpose of each?  What is the effect in each case?

12. What is Friendship and what does it do? How would you use it?

13.  How do you declare and initialize a static member variable? How do you declare and call a static function?