UML:
CODE:
void bag::get()
{
cin>>name>>num_Of_Items;
for(int i=0;i<num_Of_Items;i++)
cin>>item_Wt[i]>>item_Count[i];
}
void bag::print()
{cout<<name<<endl;}
float bag::compute()
{float f;
for(int i=0;i<num_Of_Items;i++)
f+=item_Wt[i]*item_Count[i];
return f;
}
bool wayToSort(int i,int j)
{return true;}
void solar::get()
{
cin>>num_Bags;
bag temp;
for(int i=0;i<num_Bags;i++)
{
temp.get();
m1[temp.compute()]=temp;
v.push_back(temp.compute());
}
}
void solar::sort_Vec()
{sort(v.rbegin(),v.rend());}
void solar::print_In_Order()
{
for(int i=0;i<v.size();i++)
m1[v[i]].print();
}
CODE:
void bag::get()
{
cin>>name>>num_Of_Items;
for(int i=0;i<num_Of_Items;i++)
cin>>item_Wt[i]>>item_Count[i];
}
void bag::print()
{cout<<name<<endl;}
float bag::compute()
{float f;
for(int i=0;i<num_Of_Items;i++)
f+=item_Wt[i]*item_Count[i];
return f;
}
bool wayToSort(int i,int j)
{return true;}
void solar::get()
{
cin>>num_Bags;
bag temp;
for(int i=0;i<num_Bags;i++)
{
temp.get();
m1[temp.compute()]=temp;
v.push_back(temp.compute());
}
}
void solar::sort_Vec()
{sort(v.rbegin(),v.rend());}
void solar::print_In_Order()
{
for(int i=0;i<v.size();i++)
m1[v[i]].print();
}
No comments:
Post a Comment