🍐 我们总结了加拿大代写中——C++代写的经典案例,如果你有任何代写的需要,可以随时联络我们。CoursePear™ From @2009。(cs代写)

CSI2372[A] – Fall 2021 Assignment #4

Due : 4th Dec, 2021 4:00 PM

For assignment 4, we will take the classes Person , Organization, and University
from assignment 3 and we add the template class Plist which contains an array of elements of type T.

Plist will replace the arrays we used in assignment 3 for Organization::members and Person::organizations attributes.
For example, use: Plist<T> in Person and Organization classes where T is substituted by an appropriate type. This means that the Plist class will handle all list manipulation statements (list of members or persons respectively).
The Plist template class has 4 private members:
● capacity
● size: initially is 0
● current: initially is -1
●arraycontainingelementsoftypeT: T*myarray

The class has private methods:
● get(): returns the element of the array at current index
● start(): reset current index to the first element so that the call to get() returns this first element ● next(): go to the next element
● isLast(): return True if get() returns the last element
● getCurrent(): return the current index

The PList class also has public methods:

For the logic used in defining all the public methods, you need to call only the private methods in order to iterate through the elements of the list (Use get(); start(); next()… to iterate in the list)

For example: if you want to browse the list of elements: You can’t use a loop to directly access the elements of the array

( ex: for( int i=0; i<size; i++) { array[i] … )

This is because we want to simulate the concept of iterators and how to use them to manipulate containers (lists).

Public methods:
● add(item): adds an item T to the list and throws an exception of type std::out_of_range
if the capacity is exceeded
● remove(item): remove an element T from the list. returns True if the element is removed and

T

False if the item is not found. ( Takes as parameter an object T). We have to shift all the items after removing an item
● getItem(int i): returns the element T at position i
● isFull()

● getSize()
● getCpacity()

Main() program:
You have been given a main program similar to the one in assignment 3. You need to complete the implementation of:

Note:

  registering(o0, p1);
  registering(o1, p1);
  registering(o6, p1);
  registering(o3, p1);
  registering(o7, p1);
  registering(o5, p1); //throws error : Should be caught and handled by Person

Even if the last statement throws an exception in PListe::add() , the classes (Person and Organization)must catch the exception and display the appropriate message then continue execution:

Error : Cannot add Tom to Google he is enrolled in 5 organizations already

Your classes should also display the appropriate message if one tries to remove a person who is not a member of an organization /or remove an organization that is not a member from a person’s organization list.

withdraw(o2,p1); // This should output an error message as p1 is not a member of o2

The objective of the assignment: Highlight the use of template classes by creating the template class Plist containing different types ( Person *, and Organization *)

Error Person::removeOrganization: Cannot withdraw Tom from Subway .He is not a member of

the organization

Error Organization::removePerson: Cannot withdraw Tom from Subway. Subway doesn’t have a

member Amir

Submit your assignment to Brightspace as a zip file. The top of your files must have your name and student number.

A sample run of the main() method:


CoursePear™是一家服务全球留学生的专业代写
—-我们专注提供高质靠谱的美国、加拿大、英国、澳洲、新西兰代写服务。
—-我们专注提供Essay、统计、金融、CS、经济、数学等覆盖100+专业的作业代写服务。

cs代写

CoursePear™提供各类学术服务,Essay代写Assignment代写Exam / Quiz助攻Dissertation / Thesis代写Problem Set代做等。