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.).

Answers

Answer 1

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:


Related Questions

What is the advantage of using shortcuts

Answers

Answer: There can be advantages and disadvantages.

for example, if you were in the woods with a pathway, and a clear way that might be faster and a shorter way of getting out. You may take the shortcut leading to where you didn't want to go leading to you getting lost or, it could be the same time but with more challenges.

An example of shortcuts to it's advantage is when you're reading a text and you don't understand the word. It's much easier when you hear it being read out to you when the reader uses tone to kind of give you a hint if the connotation is negative or positive, A good example of this is the word unique let's use this sentence "She was very unique, and that's what made her cool!" We can use the words "cool" to see that unique is a positive connotation! For the word cool can usually mean that something is real nice or it's something/someone you'd typically like to be around. So therefore these are just a few examples of the advantages and disadvantages of shortcuts.

Write code to play a Tic-tac-toe tournament. Tic-tac toe is a game for two players who take turns marking the spaces with Xs and Os in a 3x3 grid. The purpose of the game is to place three of your marks in a horizontal, vertical or diagonal.

Answers

Answer:

Explanation:

The following code is written in Python and is a full Two player tic tac toe game on a 3x3 grid that is represented by numbers per square.

# Making all of the main methods of the game

board = [0,1,2,

        3,4,5,

        6,7,8]

win_con = [[0,1,2],[3,4,5],[6,7,8],

           [0,3,6],[1,4,7],[2,5,8],

           [0,4,8],[2,4,6]] # possible 3-in-a-rows

def show():

   print(board[0],'|',board[1],'|',board[2])

   print('----------')

   print(board[3],'|',board[4],'|',board[5])

   print('----------')

   print(board[6],'|',board[7],'|',board[8])

def x_move(i):

   if board[i] == 'X' or board[i] == 'O':

       return print('Already taken!')

   else:

       del board[i]

       board.insert(i,'X')

def o_move(i):

   if board[i] == 'X' or board[i] == 'O':

       return print('Already taken!')

   else:

       del board[i]

       board.insert(i,'O')  

 

# Creating the main loop of the game

while True:

   turn_num = 1

   board = [0,1,2,3,4,5,6,7,8]

   print('Welcome to Tic-Tac-Toe!')

   print('AI not implemented yet.')

   while True:

       for list in win_con: #check for victor

           xnum = 0

           onum = 0

           for num in list:

               if board[num] == 'X':

                   xnum += 1

               elif board[num] == 'O':

                   onum += 1

               else:

                   pass

           if xnum == 3 or onum == 3:

               break

       if xnum == 3 or onum == 3: # break loops

           break

       if turn_num > 9: # Check if there are any more moves available

           break

       show()

       if turn_num % 2 == 1:

           print('X\'s turn.')

       else:

           print('O\'s turn.')

       move = int(input('Choose a space. '))

       if turn_num % 2 == 1:

           x_move(move)

       else:

           o_move(move)

       turn_num += 1

   if xnum == 3:  #If game ends

       print('X Won!')

   elif onum == 3:

       print('O Won!')

   else:

       print('Draw!')

   play_again = input('Play again? Y or N ')

   if play_again == 'Y' or play_again == 'y':

       continue

   else:

       break

1. Discuss the pros and cons of human-computer interaction technology?
2. Discuss the ACID database properties in details ​

Answers

!

gcoo!!Exykgvyukhhytocfplanationufvhyg:

An alternative design for a canary mechanism place the NULL value just below the return address. What is the rationale for this design decision

Answers

Answer:

This is to prevent attacks using the strcpy() and other methods that would return while copying a null character.

Explanation:

Canary is a mechanism used to monitor and prevent buffer overflow. The alternative canary design that places a null value just before the return address is called the terminator canary.

Though the mechanism prevents string attacks, the drawback of the technique is that the value of the canary is known which makes it easy for attackers to overwrite the canary.

In case of a suspected data breach, what course of action should a chief information security officer (CISO) take

Answers

Answer

1. Assemble his team

2. Find reason for breach

3. Evaluate what was lost

4. Ensure password change

Explanation:

In case of a suspected breach, the Chief information security officer should first of all assemble his incidence response team. This team should have representatives from all areas of the organization.

Then the reason for the breach and how access was gained has to be found out. An evaluation of what has been lost in the breach would be carried out and it's likely impact on the company.

In case credentials were stolen the CISO has to ensure that the employees change passwords. Also he has to notify all the necessary parties about the breach.

The CISO has to ensure that all employees are trained properly on security and they comply to security policies.

how do I make my own algorithms ​

Answers

Answer:

Step 1: Determine the goal of the algorithm. ...

Step 2: Access historic and current data. ...

Step 3: Choose the right model(s) ...

Step 4: Fine tuning. ...

Step 5: Visualise your results. ...

Step 6: Running your algorithm continuously.

Get a basic understanding of the algorithm.
Find some different learning sources.
Break the algorithm into chunks.
Start with a simple example.
Validate with a trusted implementation.
Write up your process.
Other Questions
Tell me what you think?Brainliest and points! A submarine spots a speedboat on thesurface of the water at a 42 angle ofelevation. The sub and the boat areseparated by a straight line distance of35 feet. How far beneath the surface isthe submarine traveling? I mand a question that will give you points fo free and no one haze dun it yet go and do it wen you can 5. How does this document explain how Islam spread so quickly? what is the slope and the point based on the equation: (y-2) = 5(x - 4) What is the value of 599 x (400+37)? in a class of 32 students the mean height of the 14 boys is 1.56 meters and the mean height of all 32 students is 1.151 meters. work out the mean height of girls I need the answer asappp Presented below are incomplete manufacturing cost data. Determine the missing amounts for three different situations. Direct Materials Used Direct Labor Used Factory Overhead Total Manufacturing Costs (1) $42,300 $64,000 $52,300 $ (2) $ $77,800 $144,000 $297,000 (3) $58,300 $ $115,000 $314,000 g(x) = x^2+1 h(x) = x+5 find g(x) + h(x) Write code to play a Tic-tac-toe tournament. Tic-tac toe is a game for two players who take turns marking the spaces with Xs and Os in a 3x3 grid. The purpose of the game is to place three of your marks in a horizontal, vertical or diagonal. Consider the expression 40+24 Find the greatest common factor of the two numbers and rewrite the expression using the distributive property Need help!!!Will give brainliest for answerGive oxidation and reduction half-reactions to the equation provided I really need help on this. Thank you Which of the following could describe the velocity of a rocket? PLS HELP I AM BEING TIMED FOR THINS ONE I ONLY HAVE 10 MINS PLS HELP ME ASAPWhat are the forms of light energy in solar radiation and the colors in white light? What are 4 ways you can improve your skeletal system health? Please Help if it lets me will give brainliest Decrease 16855.21 by 3.5%Give your answer rounded to 2 DP. Given f(x)=-5x+2, find f(6)