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
what is a simulation? a) simulation is the process of creating dashboards in excel. b) simulation is the process of complex form
PtichkaEL [24]

Simulation exists the imitation of the operation of a real-world process or system over time.

<h3>What is meant by Simulation?</h3>

A simulation exists an ongoing replica of how a system or process might work in the actual world. Models must be used in simulations; the model reflects the essential traits or behaviors of the chosen system or process, whilst the simulation depicts the model's development over time.

By enabling the testing of various scenarios or process improvements, a simulation is a model that replicates the operation of a current or proposed system. It provides evidence for decision-making. For a more immersive experience, this can be combined with virtual reality technology.

Therefore, the correct answer is option c) Simulation is the imitation of the operation of a real-world process or system over time.

To learn more about Simulation refer to:

brainly.com/question/28927678

#SPJ4

7 0
1 year ago
PLEASE ANSWER THIS IM IN A QUIZ
Irina18 [472]

Answer:

B. hardware problem.

Explanation:

A monitor can be defined as an electronic device that is used to graphically display data (informations) for users working on a computer.

Simply stated, a monitor is a hardware device that serves as an output source for a computer system.

If images around the edges of a monitor do not look right, the computer might have a hardware problem because the monitor of a computer is a hardware device. Common hardware problems associated with computer monitors are improper visual display, flickering, vertical lines, blotches, ink spots, random shutdown etc.

8 0
3 years ago
Read 2 more answers
Programming Objectives
erma4kov [3.2K]

Answer:

See Explaination

Explanation:

m=int(input("Please specify the number of elements in first list : "))

n=int(input("Please specify the number of elements in second list : "))

m1=1

list1=[]

n1=1

list2=[]

while m1<=m:

r1=int(input("input element {} of list1: ".format(m1)))

list1.append(r1)

m1+=1

while n1<=n:

list2.append(int(input("input element {} of list2: ".format(n1))))

n1+=1

def Intersection(list1,list2):

return set(list1).intersection(list2)

print("The intersection of two lists is {}".format(Intersection(list1,list2)))

7 0
3 years ago
What features are provided by most GUIs?
PSYCHO15rus [73]

Windows is the answer

8 0
4 years ago
Question 1 Which portion of the PuTTY package allows you to perform file transfers using the SCP (Secure Copy) protocol?
Artyom0805 [142]

There are different aspect of computing. The portion of the PuTTY package that allows you to perform file transfers using the SCP (Secure Copy) protocol is pscp.exe.

The pscp.exe tool commonly called the PuTTY Secure Copy Client is known to be the only portion of the Putty package that can let you copy files to and from remote computers through the use of the SCP.

Secure Copy (SCP)  is simply defined as a computer command that one can use in Linux to copy files from one computer to another on a network.  PuTTY is simply known to be a free implementation of SSH (and telnet) used for computer that running Microsoft Windows.

Learn more about the PuTTY package from

brainly.com/question/13171394

8 0
3 years ago
Other questions:
  • (01.05 LC)
    7·2 answers
  • Assume you need to declare a type parameter that can represent any type that implements the interface Comparable. Which type par
    15·1 answer
  • Katla is a project manager. One of the programmers on her team comes to her and says that he permanently deleted some code mista
    5·1 answer
  • When considering the best technology for its particular use, what should a business consider
    15·2 answers
  • Explain why interrupt times and dispatch delays must be limited to a hard real-time system?
    8·1 answer
  • Peer collaboration helps develop critical-thinking skills, which is the ability to
    9·2 answers
  • Which of the following options is not located in the page setup dialog box?
    14·1 answer
  • Write an Algorithm to print only numbers from 10 to n times using iteration structure
    8·1 answer
  • Using the arrow key you can adjust the position of a selection in increments of
    7·1 answer
  • You suspect that a bad video driver is causing a user's system to randomly crash and reboot. Where would you go to identify and
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!