1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
MatroZZZ [7]
3 years ago
8

One problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example

, you might want to add or delete entries from the array similar to the behavior of a vector. This project asks you to create a class called DynamicStringArray that includes member functions that allow it to emulate the behavior of a vector of strings.
The class should have:
A private member variable called dynamicArray that references a dynamic array of type string.
A private member variable called size that holds the number of entries in the array.
A default constructor that sets the dynamic array to NULL and sets size to 0.
A function that returns size.
A function named addEntry that takes a string as input. The function should create a new dynamic array one element larger than dynamicArray, copy all elements from dynamicArray into the new array, add the new string onto the end of the new array, increment size, delete the old dynamicArray, and then set dynamicArray to the new array.
A function named deleteEntry that takes a string as input. The function should search dynamicArray for the string. If not found, return false. If found, create a new dynamic array one element smaller than dynamicArray. Copy all elements except the input string into the new array, delete dynamicArray, decrement size, and return true.
A function named getEntry that takes an integer as input and returns the string at that index in dynamicArray. Return "" string if the index is out of dynamicArray’s bounds.
Overload the operator[] so that you can get and change an element by an index integer. If the index is out-of-bounds, return a "" string.
A copy constructor that makes a copy of the input object’s dynamic array.
Overload the assignment operator so that the dynamic array is properly copied to the target object.
A destructor that frees up the memory allocated to the dynamic array.
Create a suitable test program to test your class.
You should name the project ASG10. When you zip up the project folder, ASG10, include all the files (.sln, .cpp, etc) and subdirectories (Debug, etc.).
**************************************************
Copy your DynamicStringArray from Assignment 10. Fix the program so all 13 tests work properly. Modify the definition of the overloaded operator [] and getEntry so they throw an OutOfRange exception if an index that is out of range is used. OutOfRange is an exception class that you define. The exception class should have a private int member and a private string member, and a public constructor that has int and string arguments. The offending index value along with a message should be stored in the exception object. You choose the message to describe the situation. Modify your test program and add tests that catch the new exception class.
You should name the project ASG14. When you zip up the project folder, ASG14, include all the files (.sln, .cpp, etc) and subdirectories (Debug, etc.).
Computers and Technology
1 answer:
riadik2000 [5.3K]3 years ago
3 0

Answer:

Un problema con las matrices dinámicas es que una vez que se crea la matriz utilizando el nuevo operador, no se puede cambiar el tamaño. Por ejemplo, es posible que desee agregar o eliminar entradas de la matriz de manera similar al comportamiento de un vector. Este proyecto le pide que cree una clase llamada DynamicStringArray que incluye funciones miembro que le permiten emular el comportamiento de un vector de cadenas.

La clase debe tener:

Una variable miembro privada llamada dynamicArray que hace referencia a una matriz dinámica de tipo cadena.

Una variable de miembro privada llamada tamaño que contiene el número de entradas en la matriz.

Un constructor predeterminado que establece la matriz dinámica en NULL y establece el tamaño en 0.

Una función que devuelve el tamaño.

Una función llamada addEntry que toma una cadena como entrada. La función debe crear una nueva matriz dinámica un elemento más grande que dynamicArray, copiar todos los elementos de dynamicArray en la nueva matriz, agregar la nueva cadena al final de la nueva matriz, incrementar el tamaño, eliminar el antiguo dynamicArray y luego establecer dynamicArray en el nueva matriz.

Una función llamada deleteEntry que toma una cadena como entrada. La función debe buscar la cadena en dynamicArray. Si no lo encuentra, devuelva falso. Si lo encuentra, cree una nueva matriz dinámica con un elemento más pequeño que dynamicArray. Copie todos los elementos excepto la cadena de entrada en la nueva matriz, elimine DynamicArray, reduzca el tamaño y devuelva verdadero.

Una función llamada getEntry que toma un número entero como entrada y devuelve la cadena en ese índice en dynamicArray. Devuelve la cadena "" si el índice está fuera de los límites de dynamicArray.

Sobrecargue el operador [] para que pueda obtener y cambiar un elemento por un índice entero. Si el índice está fuera de los límites, devuelve una cadena "".

Un constructor de copia que hace una copia de la matriz dinámica del objeto de entrada.

Sobrecargue el operador de asignación para que la matriz dinámica se copie correctamente en el objeto de destino.

Un destructor que libera la memoria asignada a la matriz dinámica.

Cree un programa de prueba adecuado para evaluar su clase.

Debería nombrar el proyecto ASG10. Al comprimir la carpeta del proyecto, ASG10, incluya todos los archivos (.sln, .cpp, etc.) y subdirectorios (Debug, etc.).

************************************************

Copie su DynamicStringArray de la Tarea 10. Corrija el programa para que las 13 pruebas funcionen correctamente. Modifique la definición del operador sobrecargado [] y getEntry para que generen una excepción OutOfRange si se usa un índice que está fuera de rango. OutOfRange es una clase de excepción que define. La clase de excepción debe tener un miembro int privado y un miembro string privado, y un constructor público que tenga argumentos int y string. El valor del índice infractor junto con un mensaje deben almacenarse en el objeto de excepción. Tú eliges el mensaje para describir la situación. Modifique su programa de prueba y agregue pruebas que detecten la nueva clase de excepción.

Deberías nombrar

Explanation:

You might be interested in
A company wants to inform a select list of it's regular customers about a flash sale. Which type of platform will it use to send
blondinia [14]
<h2>Answer :</h2>

In case of Flash Sale, usually company uses Instant messages or SMS. As there are chances customer in most of the cases don’t have access to their emails due to internet unavailability. However SMS can be directed towards customers without the requirements of an internet. In case of SMS, there are companies available that can shoot out targeted SMS based on cities or even an entire country at a very minimal price. Company can provided them there contacts as well as they have a list of numbers from different sources to which they can send instant messages.


5 0
3 years ago
"Unicorn designs Inc., a software company, requires its employees to wear a specific color every day of the week. The colors for
marishachu [46]

Answer:

Organizational culture

Explanation:

Organizational culture is a system of shared assumptions, values, and beliefs, which governs how people behave in organizations. These shared values have a strong influence on the people in the organization and dictate how they dress, act, and perform their jobs.

8 0
3 years ago
Read 2 more answers
What can help establish the focus and organization it relies on? A) Plan B) programming C) organizing D) arranging
serg [7]

Organizational communication helps us to

1) accomplish tasks relating to specific roles and responsibilities of sales, services, and production

2) acclimate to changes through individual and organizational creativity and adaptation

3) complete tasks through the maintenance of policy, procedures, or regulations that support daily and continuous operations

4) develop relationships where “human messages are directed at people within the organization-their attitudes, morale, satisfaction, and fulfillment”

5) coordinate, plan, and control the operations of the organization through management.

So the answer is C.

hope it helps!

7 0
3 years ago
Read 2 more answers
Predictive coding software leverages .............................when experts review a subset of documents to teach the softwar
pantera1 [17]

Answer:

A.Human analysis, documents

Explanation:

Predictive coding in softwares is artificial intelligence that works by automating document review. This involves training software with data from "subset of documents" to be generally applied(apply same logic) to a larger group of documents. This is employed by a large group of technologists to ease the task of manually reviewing a huge set of documents.

7 0
3 years ago
A computer understand..............codes.<br>​
KiRa [710]

Answer:Computers only understand machine code - they do not understand high-level language code. Any high-level programming language code has to be converted to executable code. Executable code is also known as machine code which is a combination of binary code 0s and 1s.

Explanation:

6 0
2 years ago
Other questions:
  • Which of these statements is true?
    9·1 answer
  • What is the central unit of the computer that contains the logic circuitry and carries out the instructions of the computer's pr
    13·1 answer
  • Write a program that accepts three decimal numbers as input and outputs their sums?​
    5·1 answer
  • What is 450 g of flour a measure of?
    11·1 answer
  • What are the advantages and disadvantages of the various collision resolution strategies for hashes?
    7·2 answers
  • Most 4 year colleges want an applicant's scores for all the following except
    12·1 answer
  • A-1 grdening supply is preparing a reprt to hand out to the customerez in pointes form only.why should the reprts writers avoid
    9·2 answers
  • Correct all the mistakes in the following sentence:
    15·2 answers
  • HELP ME PLEASE ASAP
    6·1 answer
  • Tres areas donde se aplica la ciencia y tecnologia
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!