Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions IPA2/footwearProgram.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,39 @@ public static int getCountByType(Footwear[] ft, String t)
return 0;
}
}

public static Footwear getSecondHighestPriceByBrand(Footwear[] ft, String name)
{
for(int i =0; i<ft.length; i++)
public static Footwear getSecondHighestPriceByBrand(Footwear[] ft, String name){
Footwear highest = null;
Footwear secondHighest = null;

for(int i = 0; i < ft.length; i++)
{
if(ft[i].getName().equalsIgnoreCase(name))
{
return ft[i];
if(highest == null || ft[i].getPrice() > highest.getPrice())
{
secondHighest = highest;
highest = ft[i];
}
else if(secondHighest == null || ft[i].getPrice() > secondHighest.getPrice())
{
secondHighest = ft[i];
}
}
}
return null;

return secondHighest;
}
// public static Footwear getSecondHighestPriceByBrand(Footwear[] ft, String name)
// {
// for(int i =0; i<ft.length; i++)
// {
// if(ft[i].getName().equalsIgnoreCase(name))
// {
// return ft[i];
// }
// }
// return null;
// }
}

class Footwear
Expand Down