Question: Package Explorer X Lab1Sol lab2Sol JRE System Library [JavaSE-17] src cus1156fall2022lab2 J Cat.java JCatList.java CatListSortTest.java Practice Week1 Week2 Week3 1 1 2 3 4
![Package Explorer X Lab1Sol lab2Sol JRE System Library [JavaSE-17] src cus1156fall2022lab2 J](https://s3.amazonaws.com/si.experts.images/answers/2024/02/65bc5e07a4d24_65565bc5e0773627.jpg)

Package Explorer X Lab1Sol lab2Sol JRE System Library [JavaSE-17] src cus1156fall2022lab2 J Cat.java JCatList.java CatListSortTest.java Practice Week1 Week2 Week3 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 160 18991 17 19 20 21 22 23 24 25 26 27 28 29 300 31 32 33 34 350 36 37 38 390 40 41 1 42 43 44 45 46 47 480 BankAccount.jav 49 50 51 52 53 54 55 56 57- 58 59 60 61 62- 63 64 65 66 67 68 690 70 71 2 73 74 75 76 7 78 79 72 740 77 J T } /** *This class represents a cat * @author Bonnie K. MacKellar */ public class Cat { private String name; private String color; BankAccount Test /** * create a default cat */ public public Cat () { /** * create a cat of a given name and color * * @param name - the cat's name * @param color the cat's color. */ public Cat (String name, String color) { this.name = name; this.color = color; } /** * get the cat's color * * @return the color */ public String getColor() { return color; } /** * set the cat's color * * @param color color of the cat */ public void setColor (String color) { this.color = color; } /** * get the cat's name * * @return the cat's name */ public String getName() { return name; } /** * set the cat's name * * @param name */ public void setName(String name) { this.name = name; } } /** * make the cat meow banktester.java */ public void meow () { System.out.println("Hi, my name is " + name); System.out.println("Meow!"); public String toString() { return "Cat [name=" + name + ", color=" + color + "]"; } Writable Hamster.java Smart Insert HamsterFun.java 1:1:0 J Comparator Lambd JCat.java X 48 Q 8 22 0 4 + 29 4 Tok D Package Explorer X Lab1Sol lab2Sol JRE System Library [JavaSE-17] src cus1156fall2022lab2 JCat.java JCatList.java CatListSortTest.java Practice Week1 Week2 Week3 0 222G BankAccount.jav 1 125678 60 /** * Represents a list of cats * 9 * @author Bonnie MacKellar 10 * 11 */ 12 public class CatList { 13 14 150 16 17 18 19 200 21 22 23 240 25 26 27 28 2 import java.util.ArrayList; 4567 OSONM 33 290 30 31 1234O 32 330 34 35 36 37 380 39 40 41 69 420 43 45 44 45 A460 47 48 49 50 51 52 53 540 BFSGFWN T 55 56 57 } 58 BankAccount Test } private ArrayList cats = new ArrayList (); /** * add one cat to the list, at the last position * * @param cat a Cat to be added */ public void addCat (Cat cat) { cats.add(cat); /** * return the number of cats in the list * * @return number of cats in the list */ public int howManyCats () { return cats.size(); } banktester.java /** * return the cat at the ith position * * @param pos the position whose Cat we want to return */ public Cat getCatAtPos(int pos) { return cats.get(pos); } } } /** * return a formatted string containing cat information for all the cats on the * list */ public String toString() { String newline = System.getProperty("line.separator"); String str = ""; for (Cat currCat : cats) Hamster.java str + currCat + newline; return str; Writable Comparator Lambd public List getCats ByColor (String color) { return (cats.stream().filter (cat -> cat.getColor().equals(color)).collect (Collectors.toList())); Smart Insert JCat.java 27:25: 489 CatList.java X 49 Q 8 22 0 W 43 Tok D Package Explorer X Lab1Sol lab2Sol JRE System Library [JavaSE-17] src cus1156fall2022lab2 J Cat.java JCatList.java CatListSortTest.java Practice Week1 Week2 Week3 1 L2345STOSANASSAB9OANELE BankAccount.jav 1 6 3 public class CatListSortTest { 7 8 10 11 50 public static void main(String[] args) { CatList cats = new CatList(); System.out.println("will create the cats"); cats.addCat (new Cat ("Fluffy", "gray")); cats.addCat (new Cat ("Zoe", "black")); cats.addCat (new Cat ("Xiongmao", "spotted")); cats.addCat (new Cat ("Little Kitty", "calico")); cats.addCat (new Cat ("Angus", "gray")); 12 13 14 15 222 16 17 18 19 20 21 22 J 24 25 } T 26 BankAccount Test } banktester.java JComparatorLambd System.out.println("Here is the list"); System.out.println(cats); "I System.out.println("There are + cats.howManyCats () + /* ArrayList sorted Cats = cats.getCats SortedByName(); System.out.println("Here are the sorted cats"); System.out.println(sorted Cats); System.out.println("Here is the original list");*/ System.out.println(cats); Writable Smart Insert Cat.java cats on the list"); 1:1:0 JCatList.java JCatListSortTest X >> 50 Q 8 22 U 4 + 43 Tok D
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
