Question
Need this code in C++ and Java In this homework, you will work on object oriented programing and mainly compare some features of C++ and
Need this code in C++ and Java
In this homework, you will work on object oriented programing and mainly compare some features of C++ and Java. You will construct an array manipulation class named arrayPlay in C++ with the following features: 1. The private data members of your class be an array, its size, and other members according to your need. 2. Two constructors a. A default constructor with a default size (e.g. 15). b. The second constructor will take an array as argument as initial values. You can also define its capacity for your private array. If you need other parameters, you can also pass so. 3. The following accessor methods a. capacity () - return its capacity/size. b. isEmpty () - return true if there is no item in the array, false otherwise. c. noOfItems () - total number of items in the array. d. printArray () - print out all array items. 4. The following operations a. add ( ) - if there is free space, add the item (passed through parameter) at the end of the array. b. add ( ) - it will take an array as a parameter and add the items at the end of the private array of your class; if there is not enough space for all items, you will add as many items as you can. c. sort () sort the array in ascending order. d. find ( ) search an item in your array, return index if success, -1 otherwise. e. deleteItem ( ) delete the passed item as parameter if it is present. A sample class: class arrayPlay{ private: int *a; int size; int last; public: arrayPlay(); // means define parameters as your need arrayPlay(); // means define parameters as your need int capacity();// means define parameters as your need bool isEmpty() int noOfItems(); void add( ); // means define parameters as your need void add( ); // means define parameters as your need void printArray(); void sort(); int find(int x); void deleteItem(int x); }; Write sample testing code inside the main method that test all methods you have implemented. You will also implement the same program in Java.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started