program to create a room class,with the attributes roomNo,roomType,roomArea and ACmachine, with function setdata ,displaydata | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

program to create a room class,with the attributes roomNo,roomType,roomArea and ACmachine, with function setdata ,displaydata

3rd Sep 2019, 4:03 PM
mary uiru
10 Answers
+ 1
well, what do you need help with? (it wouldn't help you if we just gave you a working code, you'd fail in the exam(s) 😅)
3rd Sep 2019, 4:36 PM
Anton Böhler
Anton Böhler - avatar
+ 1
I guess java... public class Room{ private int number; private int area; private String acMachine; public Room(){ //here need to be parameters //this you can do your self } public void setNumber(int num){ number = num; } public void setArea(int a){ area = a; } public void setACMachine(String s){ acMachine = s; } public void displayData(){ //this you can do your self ... } }
3rd Sep 2019, 5:07 PM
Anton Böhler
Anton Böhler - avatar
0
I tried several codes but they weren't working
3rd Sep 2019, 4:42 PM
mary uiru
0
ups type is missing 😅 well you can add it yourself too, I think now you'll be able to 😅
3rd Sep 2019, 5:09 PM
Anton Böhler
Anton Böhler - avatar
0
Thanks a lot 🙏 Lemme try executing it
3rd Sep 2019, 5:16 PM
mary uiru
0
Why are the access specifiers of the attributes private?
3rd Sep 2019, 5:20 PM
mary uiru
0
in java you almost always do private to prevent anyone from modyfing them. And because you have the method setdata, which means they should be private otherwise the method wouldn't make sense ... 😅
3rd Sep 2019, 5:24 PM
Anton Böhler
Anton Böhler - avatar
- 1
do you have attempts? is this an school assingment?
3rd Sep 2019, 4:24 PM
Anton Böhler
Anton Böhler - avatar
- 1
Yes,it is
3rd Sep 2019, 4:27 PM
mary uiru
- 2
How do I create those functions and attributes?
3rd Sep 2019, 4:55 PM
mary uiru