Find Jobs
Hire Freelancers

C++ Assignment2

$10-30 USD

Completed
Posted almost 10 years ago

$10-30 USD

Paid on delivery
Write a 'Set' template class. NOTE: There's a "set" class in the C++ Standard Library, but don't use it. HINT: Make use of the "Vector" class from the C++ Standard Library to help implement your Set class A 'Set' is a collection of elements in which no two elements are equal. All elements in one set are of the same data-type. This data-type can be anything: a built-in data type, an object, or a pointer to a built-in datatype or object. For a set whose elements are objects, the object class must have an overloaded "operator==" method, so that the Set can determine if two objects are equal. Write the following public Set methods: Set(); // Constructor: create empty set. bool Add(T elmt); // add another element to the set. 'true' if added. // T is the data-type of each element in the se. bool Remove(T v); // remove from the set the element equal to 'v'. // Return 'false' if no such element was in the set. int Size(); // return number of elements in the Set. static int NSets(); // return number of sets that are in existence // that contain elements of this datatype. // the following 3 Set methods can be used to sequentially // retrieve each element in the set: T getFirst(); // returns the "first" element in the set. T getNext(); // returns the "next" element in the set (or the last elmt). T getLast(); // returns the "last" element in the set. If the Set is empty and getFirst, getNext, or getLast is called, there is no object these functions can return. So just print an error message and terminate the program. Below is a main program to partially test Set class. You'll need to add some "cout" statements. The main program uses class Circle. You can download Circle.h and Circle.cpp. int main() { Set<float> fset; // a set of floats. Set<Circle> pset; // a set of Circles. Circle c(0.,0.,3.0); //a circle centered at (0,0) radius 3.0 Circle c2(0.,0.,3.0); //another circle centered at (0,0) radius 3.0 Circle c3(1.,0.,3.0); //a circle centered at (1,0) radius 3.0 bool ok; ok=[login to view URL](c); // add circle c to the set ok=[login to view URL](c2); // add circle c to the set. Make sure "ok" is false. if (ok==false) cout<<"Can't add c2 to set"<<endl; ok=[login to view URL](c3); int n=[login to view URL](); // get size of the set, insure n is 2. ok=[login to view URL](c); // remove circle c from the set. Insure ok is true. int nset=Set<float>::NSets(); //insure nset is 1. cout<<"Number of float sets = "<<nset<<endl; nset=Set<Circle>::NSets(); // insure nset is 1. cout<<"Number of Circle sets = "<<nset<<endl; for (int i=0; i<6; i++) // add 6 floats to 'fset': 0,2,4,6,8,10 [login to view URL](i*2.0); // retrieve each float in the set 'fset'; float elmt; for (elmt = [login to view URL](); true; elmt=[login to view URL]()) { // insure each different float value is printed. cout<<"elmt="<<elmt<<endl; if (elmt == [login to view URL]()) break; // end the loop } } HINT2: Only use the vector 'begin()' method
Project ID: 5800487

About the project

5 proposals
Remote project
Active 10 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hello. We worked at previous time, there is quite easy assignment for me,. I am expert in C++, and I will not use set and I know how to use std::vector for this project
$15 USD in 1 day
4.9 (232 reviews)
6.1
6.1
5 freelancers are bidding on average $20 USD for this job
User Avatar
Hi I am C/C++ expert , to help you out in this project , please ping me to discuss, i will provide complete code with comments
$35 USD in 1 day
5.0 (7 reviews)
2.8
2.8
User Avatar
hi, i am goon in c++ , i can do this simple project in short time. i have done several console/desktop applications. i am confident with my sill that i can able to finnish this task easily. Thanks, Tristan
$15 USD in 1 day
4.7 (3 reviews)
1.9
1.9
User Avatar
A proposal has not yet been provided
$20 USD in 1 day
5.0 (1 review)
0.8
0.8
User Avatar
Hi It is a small project. I am a c/c++ expert, but a new freelancer. If you award me, I can a standard c++ program. I hope it is my first project, and just 5 stars. Thank you.
$15 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
California, United States
5.0
3
Payment method verified
Member since Nov 27, 2013

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.