Concept explainers
using C++
1- Creates a class called Member with two integer x and y.
a. Add a constructor able to create a Member object with tow integers and the default values 0,0.
b. Add the methods setX and setY to modify the attributes x and y; [2 Mark
c. Add the method display able to display the attributes.
2- A Stack is a special array where the insertion and deletion will be via a specific index called "head". A Stack is characterized by 3 attributes:
a. capacity (int): the maximum number element Member that can be contained into the Stack.
b. head: presents the index where we can add/remove element to the Stack. The head value presents also the current number of elements into the Stack. When a Stack is created the initial value of head is 0.
c. Member content[]: an array of elements of type Member.
Creates the class Stack with the following methods:
a. bool empty(): this method returns true if no element exists in the Stack.
b. bool full(): this method returns true if there are no place to add a new
element to the Stack.
c. overload the operator += (Member): able to add an element to the Stack. You need to be sure that there is an available space in the Stack: (use assert (condition); from <cassert>, the condition must describe the existence of an available space). When a member is added, the head index will be increased.
d. delete(): able to delete an element from the Stack. You need to be sure that there is at least one available member in the Stack (use the assert function). When a member is deleted, the head index will be decreased.
e. display(): a method able to display all the member elements existing in
the Stack;
3- Creates a function main() to test the program:
a. Creates a Stack.
b. Creates 3 Members and then insert all of them into the Stack.
c. Display the Stack.
d. Delete an element from the Stack.
e. Display the Stack for one more time.
Step by stepSolved in 4 steps with 2 images
- Data Structure & Algorithm: Show by fully java coded examples how any two search algorithms work. You should test these with various array sizes and run them several times and record the execution times. At least four array sizes are recommended. 10, 20, 30, 40. It is recommended you write the classes and then demonstrate/test them using another class. Discuss the comparative efficiencies of your two chosen search algorithms.arrow_forwardGiven the previous Car class, the following members have been added for you: Private: string * parts; //string array of part names int num_parts; //number of parts Public: void setParts(int numpart, string newparts[]) //set the numparts and parts int getNumParts() string * getParts() string getPart(int index) //return the string in parts at index num Please implement the following for the Car class: Add the copy constructor. (deep copy!) Add the copy assignment operator. (deep copy!) Add the destructorarrow_forwardWritten in Python It should have an init method that takes two values and uses them to initialize the data members. It should have a get_age method. Docstrings for modules, functions, classes, and methodsarrow_forward
- Smart Pointer: Write a smart pointer class. A smart pointer is a data type, usually implemented with templates, that simulates a pointer while also providing automatic garbage collection. It automatically counts the number of references to a SmartPointer<?> object and frees the object of type T when the reference count hits zero.arrow_forward10. Lottery Application Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constructor should use the Random class (from the Java API) to generate a random number in the range of 0 through 9 for each element in the array. The class should also have a method that accepts an array of five integers that represent a per- son's lottery picks. The method is to compare the corresponding elements in the two arrays and return the number of digits that match. For example, the following shows the lotteryNumbers array and the user's array with sample numbers stored in each. There are two matching digits (elements 2 and 4). lotteryNumbers array: User's array: 7 4 4 2 1 3 7 3 In addition, the class should have a method that returns a copy of the lotteryNumbers array. Demonstrate the class in a program that asks the user to enter five numbers. The program should display the number of digits that match the randomly generated…arrow_forwardDeclare a student structure that contains : Student's first and last nameStudent IDCreate the following functions: getStudentInfo(void) Declares a single student, uses printf()/scanf() to get inputReturns the single student backprintStudentInfo(student_t *st_ptr) Takes the pointer to a student (to avoid making a copy)Prints out all of the student informationDeclare an array of five studentsUsing a for loop and getStudentInfo() function, get input of all the studentsUsing a for loop and printStudentInfo() function, print all the output of all students.arrow_forward
- 11:02 all 10% + Create 1 1000.01 Create 2 2000.02 Create 3 3000.03 Deposit 111.11 Deposit 2 22.22 Withdraw 4 5000.00 Create 4 4000.04 Withdraw 1 0.10 Balance 2 Withdraw 2 0.20 Deposit 3 33.33 Withdraw 4 0.40 Bad Command 65 Balance 1 Balance 2 Balance 3 Balance 4arrow_forwardJava code 8. Given an existing ArrayList named friendList, find the first index of a friend named Sasha and store it in a new variable named index. 9. Given that an ArrayList of Integers named numberList has already been created and several values have already been inserted, write the statement necessary to insert the value 25 at the end of the list. 10. Declare an integer array named evens and fill it with even numbers from 2 through 10 in one statement. 11. Given an existing array named pets, find the size of the array and store it in a new variable named numPets. 12. Given an existing ArrayList named contactList, find the number of contacts in the ArrayList and store it in the existing variable named numContacts.arrow_forwardData Structure & Algorithm: Show by fully java coded examples how any two sorting algorithms work. You should test these with various array sizes and run them several times and record the execution times. At least four array sizes are recommended. 15, 20, 25, 30. It is recommended you write the classes and then demonstrate/test them using another class. Discuss the comparative efficiencies of your two chosen sorting algorithms.arrow_forward
- Java - Gift Exchange *** Please include UML Diagram and notes in code Minimum requirements are: At least 1 loop An Array or ArrayList At least 3 Java classes Use methods I am trying to make it so that the program will: Prompt for the number of people included in exchange - If not even it will state that there has to be an even number and ask for the number of people included again (loops). Prompt to enter a participant's first name Prompt for the participant's age Print out the random matching of participants so that everyone gets a gift and everyone gives a gift. Please include UML Diagramarrow_forwardIN C++ Lab #6: Shapes Create a class named Point. private attributes x and y of integer type. Create a class named Shape. private attributes: Point points[6] int howManyPoints; Create a Main Menu: Add a Triangle shape Add a Rectangle shape Add a Pentagon shape Add a Hexagon shape Exit All class functions should be well defined in the scope of this lab. Use operator overloading for the array in Shape class. Once you ask the points of any shape it will display in the terminal the points added.arrow_forwardcreate using c++ 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 the following 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…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education