the name of the Lab. name: the location (room and building numbers) of the Lab. location: Methods: constructor Lab(name: String, location: String): this method adds the equipment to the Lab. This method addEquipment (e: Equipment): e raises an ArrayOutOfBoundException exception if the array is full. arrEq this method saves all equipment objects of type LapTop SaveLaptops (fileName: String): in the file which name is passed in the parameter fileName. this method reads equipment objects from the file readAddPrinters(fileName: String): fileName and adds the read printers to the array of the lab. The different exceptions arrEq should be handled separately. this method returns the number of printers of the Lab having a speed getNbPrinters(s: int): greater than If the parameter is less than 15, this method raises an Exception. s. s this method returns an array containing all printers of the Lab having a getPrinters(s: int): speed greater than Make sure that the array should not contain empty cells (the length of s. the returned array should be exactly equal to the number of the selected printers). QUESTION: Translate into Java code the class Lab. Exercise 4: the same class described in exercise 2. Lab Let’s consider class: LinkedListOfLabs Methods: constructor LinkedListOfLabs(): this method adds the Lab at the beginning of the list. insertAtFront (l: Lab): l this method adds the Lab at the end of the list. insertAtBack (l: Lab): l this method counts and returns the number of labs having printers with countLabs (s: int): a speed greater than s. LinkedListOfLabs, LinkedListOfLabs, int): This method inserts split(labList1: labList2: s: into all labs having printers with a speed greater than It inserts all other labs into labList1 s. The labs of should be ordered in the same order than the original list. labList2. labList1 The labs of should be ordered in the reverse order than the original list. labList2
name: the name of the Lab. location: the location (room and building numbers) of the Lab. Methods: Lab(name: String, location: String): constructor addEquipment (e: Equipment): this method adds the equipment e to the Lab. This method raises an ArrayOutOfBoundException exception if the array arrEq is full. SaveLaptops (fileName: String): this method saves all equipment objects of type LapTop in the file which name is passed in the parameter fileName. readAddPrinters(fileName: String): this method reads equipment objects from the file fileName and adds the read printers to the array arrEq of the lab. The different exceptions should be handled separately. getNbPrinters(s: int): this method returns the number of printers of the Lab having a speed greater than s. If the parameter s is less than 15, this method raises an Exception. getPrinters(s: int): this method returns an array containing all printers of the Lab having a speed greater than s. Make sure that the array should not contain empty cells (the length of the returned array should be exactly equal to the number of the selected printers). QUESTION: Translate into Java code the class Lab. Exercise 4: Let’s consider the same class Lab described in exercise 2. LinkedListOfLabs class: Methods: LinkedListOfLabs(): constructor insertAtFront (l: Lab): this method adds the Lab l at the beginning of the list. insertAtBack (l: Lab): this method adds the Lab l at the end of the list. countLabs (s: int): this method counts and returns the number of labs having printers with a speed greater than s. split(labList1: LinkedListOfLabs, labList2: LinkedListOfLabs, s: int): This method inserts into labList1 all labs having printers with a speed greater than s. It inserts all other labs into labList2. The labs of labList1 should be ordered in the same order than the original list. The labs of labList2 should be ordered in the reverse order than the original list.
finalexamspring2015.docx