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]
2 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]2 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
What is the formula for determining the number of possible hosts on a network?
fredd [130]
2**(32 - netmask) - 2 = number of nodes available

The netmask is in CIDR (Common Internet Domain Routing) notation, without the slash.

One of the nodes would be needed for a router or else you can't communicate with other networks.
3 0
2 years ago
Many inventions have enabled us to use digital cameras. The biggest difference between traditional and digital cameras is that d
Andreyy89

1 Film Roll Vs SD card.

2 No LCD Display Vs LCD Display

3 No mega Pixels Vs Mega Pixels

4 Zero Optical zoom Vs Optical Zoom

5 No Picture Modes Vs Different Picture Modes

6 Limited Number of Pics per roll Vs unlimited number of pictures depending upon the size of a Card

7 Hassle of developing pictures Vs no hassle, simply transfer them to the pc/laptop

8 Limited features Vs multiple features

hope this helps

8 0
3 years ago
Edhesive code practice 4.8 Question 3
vovangra [49]

Answer:

for i in range(200,301,2):

  print(i)

Explanation:

just copy and paste 100 percent

3 0
2 years ago
Read 2 more answers
Write a program that prompts the user for two numbers then outputs the result of dividing the first number by the second number
Rainbow [258]

The program is

num = int(input("Enter Numerator "))

den = int(input("Enter Denominator "))

print("quotient is ",str(num//den)," remainder is ", str(num%den))

<h3>How to create a division sign in HTML?</h3>

To create a division sign ( ÷ ) in HTML you can use any of the following codes.

&divide;

&div;

&#247;

<h3>How to divide in computer programming?</h3>

Perl code

use strict;

my $first = 15;

my $second = 5;

my $answer = $first / $second;

print "You get $answer if you divide $first by $second";

When the script above is run, it displays "You get 3 if you divide 15 by 5" on the screen.

To learn more about programming, refer

https://brainly.ph/question/4743

#SPJ4

5 0
1 year ago
Why would students most likely need to collect data? Check all that apply
n200080 [17]
Well I would think all of them in some way. For the first one, students need to collect data (whether it’s mathematical, scientific, etc.) to answer a question. For the second one, they may need to know how much money is in there bank account or they may need to calculate a sale to order the item. For the third one, they may need statistical data to support a position. For the last one, a student could use technological data to be able to solve their problem sorting documents.
5 0
3 years ago
Read 2 more answers
Other questions:
  • Judy forgot where she saved a certain file on her computer. Therefor, she searches for all files with a jpg file extension. Whic
    11·2 answers
  • Please use Python 3 to solve the following problem. Please also show all outputs and share code.The variable sentence stores a s
    6·1 answer
  • Given :an int variable k,an int array currentMembers that has been declared and initialized ,an int variable nMembers that conta
    12·1 answer
  • Write a program to calculate and return total surface area of a box using FUNCTION _END FUNCTION.​
    15·1 answer
  • A star appears under the <br> menu of the word processing program.
    5·1 answer
  • Software applications called _____ provide the means to record information that passes through a computer or router that is hand
    10·1 answer
  • Which option should you select to ignore all tracked changes in a document? To ignore all tracked changes in a document, you sho
    15·2 answers
  • __________ are the first line of defense against unsafe drivers.
    5·1 answer
  • C:/Users/Documents/resume.docx Where is the "resume" document located in this file structure?
    12·1 answer
  • Please help me !!
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!