x140 { نظيم كل FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY DEPARTMENT OF Computer Engineering QUESTION NO. 2: MAND
Posted: Sun Jul 03, 2022 11:23 am
QUESTION NO. 2: MANDATORY/OPTIONAL/BONUS (mants) - a) Suppose a Lamp is described by its color and whether it is turned on or not. Write a class Lamp that contains: > A constructor that creates an object with initial values for color and whether the lamp is on or off, >A print method to print Lamp info with spaces between them. Implement the encapsulation principle. class Lamp Private Strinco lot; islonce venoble public Public Lamp (colub) this.colt colet; } Public boolean (string) if (this color // other color) nultetain/1 else Sit Iloko = returio othekculux e sch Lamp[3 m new Lamp[2]; m[-] = new lamp (ted) mais new Lamp (green) (10 POINTS) AAO-P10-R01 3 2018/9/30 Page 3 of 4 Principles of Object Oriented Programming (110112010) -2 O 12:12 ص 2 © b) Write a testing class that runs creates an array of 2 Lamp objects and then run the print method on the elements of the array. (4 Points) class testy publi't stohc vorp for (Lampen) system.out.println (m). getelice); e ■ (6 Points) 2
x140 { نظيم كل FACULTY OF ENGINEERING AND INFORMATION TECHNOLOGY DEPARTMENT OF Computer Engineering