Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // put this is main
- for (int x = 0; x < inventory.length - 1; x++) {
- iYear = inventory[x].getYear();
- sYear = Integer.toString(iYear);
- if (!sYearFound.contains(sYear)) {
- if (IsYearFound(x, iYear)) {
- sYearFound += "||" + sYear + "||";
- }
- }
- }
- // add this method
- private static boolean IsYearFound(int x, int iYear) {
- boolean bRetVal = false;
- String sMessage = "";
- for (int i = x + 1; i < inventory.length; i++) {
- if (inventory[i].getYear() == iYear) {
- sMessage += i + "and \n " + inventory[i].toString();
- bRetVal = true;
- }
- }
- if (bRetVal == true) {
- System.out.println("Year of " + inventory[x].getYear() + " is equal for the objects at index : " + x +" " + inventory[x].toString() + sMessage);
- }
- return bRetVal;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement