Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the constructor of class HouseList, which is suppossed to be a singly -

ID: 3775889 • Letter: C

Question

Complete the constructor of class HouseList, which is suppossed to be a singly - Linked list of Houses with a head (dummy) node: Public class HouseList} Public HouseListNode first; Public HouseList Node Last; Public int length; Public class HouseList Node} Public House Data; Public HouseListNode Nexr; Public HouseList ()} Assuming class House has a made method called get Rooms which returns as an integer the number of rooms in the house, write a method for class HouseList that will return how many houses on the List which have a given number of rooms. Public int count Houses (int Number of Rooms)}

Explanation / Answer

public class HouseList { public HouseListNode first; public HouseListNode last; public int length; public HouseList(){ HouseListNode head = new HouseListNode(); head.Data = null; head.Next = null; first = head; last = head; length = 0; } public int countHouses(int numberOfRooms){ int count = 0; HouseListNode temp = first; while(temp.Next != null){ temp = temp.Next; if(temp.Data.getRooms() == numberOfRooms) ++count; } return count; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote