Given the following class with a method to get the weight, how would I write a class that can contain many of them and write a method to find the one with the largest weight?
public class Item{
int weight;
public int GetWeight(){
return weight;
}
}
public class ItemContainer{
Item[] items;
public Item GetMaxWeight(){
//find Item with largest weight
}
}
You could use a variable to track it as well.