0

Can anyone help me?

create a program that use class and objects concepts in one interrelated program

20th Jun 2022, 3:45 PM
JELLY GUTIERREZ
JELLY GUTIERREZ - avatar
5 odpowiedzi
+ 2
Well… what about a class saving the length and width of a rectangle and providing the area and circumference as method? Sound like a nice idea in my ears…. Other than that: if you specify which language you want to use and post and attempt/describe the problem you experience, i am sure we can help you out creating such a program
20th Jun 2022, 3:52 PM
Alexander Thiem
Alexander Thiem - avatar
+ 2
Please avoid writing the question in the post's tags, it ruins the search engine's performance. https://code.sololearn.com/W3uiji9X28C1/?ref=app
20th Jun 2022, 3:56 PM
Ipang
0
#include <iostream> using namespace std; class Queue { int size; int* queue; public: Queue() { size = 0; queue = new int[100]; } void remove() { if (size == 0) { cout << "Queue is empty"<<endl; return; } else { for (int i = 0; i < size - 1; i++) { queue[i] = queue[i + 1]; } size--; } } void print() { if (size == 0) { cout << "Queue is empty"<<endl; return; } for (int i = 0; i < size; i++) { cout<<queue[i]<<" <- "; } cout <<endl; } //your code goes here void add( int newData ) { if( size != 0 || size != 100 ) { size++; //increment size queue[size-1] = newData; //make new element as the last element } } }; int main() { Queue q; q.add(42); q.add(2); q.add(8); q.add(1); q.print(); q.remove(); q.add(128); q.print(); q.remove(); q.remove(); q.print(); return 0; } It's something like this.
20th Jun 2022, 3:55 PM
JELLY GUTIERREZ
JELLY GUTIERREZ - avatar
0
C++ language
20th Jun 2022, 3:55 PM
JELLY GUTIERREZ
JELLY GUTIERREZ - avatar
0
I would check for size!=0 AND size!=100 Other than that it looks fine to me… what is the problem? (You might want to create a code in code playground and link it here, then we can just run it and see)
20th Jun 2022, 4:00 PM
Alexander Thiem
Alexander Thiem - avatar