arkadaşlar merhaba ben şu a yurtdışında erasmus oğrencisiyim ve hocam cok katı derdimi bir turlu anlatamıyorum.Ben bundan iki sene once c dersi aldım ve haliyle unutmuşum iki haftadır C++ ile ilgili video falan izliyorum ama yapamadım onceki odevlerimi cok uğraşmama rağmen.Şu an bir odev verdi ve teslim edemezsem beni bırakacak lutfen arkadaşlar acil yardımınıza ihtiyacım var.Lutfen cevaplarınızı bekliyorum...
*****************
Course: Basics of programming II
Spring Semester, 2012
Homework Assignment
HWA-4
In computer science, a SET is an abstract data structure that can store certain values, without any particular order, and no repeated values. It is a computer implementation of the mathematical concept of a finite set. Some set data structures are designed for static sets that do not change with time, and allow only query operations — such as checking whether a given value is in the set, or enumerating the values in some arbitrary order. Other variants, called dynamic or mutable sets, allow also the insertion and/or deletion of elements from the set.
FIFO is an acronym for First In, First Out, an abstraction in ways of organizing and manipulation of data relative to time and prioritization. In computer science this term refers to the way data stored in a queue is processed. Each item in the queue is stored in a queue data structure. The first data to be added to the queue will be the first data to be removed, then processing proceeds sequentially in the same order.
1. Develop and implement a Set class.
a) Download the files Set.h and SetMain.cpp from the website and include them into the project to Header Files and Source Files folders respectively.
b) Create the Set.cpp file in Source Files folder and implement it yourself based on the downloaded Set.h class declarations.
c) Run the test cases, following the instructions in SetMain.cpp. Observe the program execution in debugger mode.
d) Add a new function to the class, which empties the set: empty().
e) What is the difference between the function empty() and the destructor of the class? Write your answer in a separate answers.txt file.
Files to submit: Set.h, SetMain.cpp, Set.cpp, answers.txt.
2. Develop and implement a FIFO class. Use the Set class from Task 1 as an example. Consider the following mandatory functions and restrictions:
a) The operation push inserts an element, and the operation pop returns the firstly entered element.
b) Follow the principles of encapsulation: do not allow making the container inconsistent from the outside.
c) Take care about dynamic memory management.
d) Based on the tests that can be found in SetMain.cpp, create test cases for FIFO class.
Files to submit: Fifo.h, FifoMain.cpp, Fifo.cpp.
Please do this HWA individually. The solution will be checked by the CL Instructor.
The not presented homework will be marked as “Fail”. The identical homeworks are considered as plagiarism. All parties involved in plagiarism will be prosecuted no matter who copied from whom. It is your duty to keep your code secure.
**************************
verilen set.h dosyası
#ifndef SET_H
#define SET_H
// Files for HWA-4, Basics of Programming II
class Set
;
#endif
*************
verilen SetMain.cpp dosyası
#include"Set.h"
void printSet(Set s);
void printSet(Set* ps);
void printSet(Set s)
void printSet(Set* ps)
int main(void)
// Put a breakpoint at the begining of copy constructor to see when is it called!
// Testing the copy constructor
Set s2(s1); // explicit constructor call
Set s3=s1; // just initialization
printSet(s1); // value based parameter passing - copy constructor is called
printSet(s2); // value based parameter passing - copy constructor is called
printSet(&s3); // reference based parameter passing - copy constructor is NOT called (check it by observing the breakpoint)
s2.remove(1); // testing remove operation
printSet(s2); // checking the result
printSet(s1); // checking if the other one is modified (possible reason: bad copy constructor)
s2.remove(1); // testing remove operation (in debugger mode we should see that it returns false)
return 0;
}
/* After executing it for the first time, modify the following function
void printSet(Set s);
to have a reference type parameter:
void printSet(Set &s);
Remember to do it twice: in the definition (implementation) of the function and in the prototype (header) as well.
*
__________________
odev
Android & IOS Uygulama Geliştirme0 Mesaj
●28 Görüntüleme