+ 3
program to create a room class,with the attributes roomNo,roomType,roomArea and ACmachine, with function setdata ,displaydata
10 Antworten
+ 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) 😅)
+ 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 ...
}
}
0
I tried several codes but they weren't working
0
ups type is missing 😅
well you can add it yourself too, I think now you'll be able to 😅
0
Thanks a lot 🙏
Lemme try executing it
0
Why are the access specifiers of the attributes private?
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 ... 😅
- 1
do you have attempts? is this an school assingment?
- 1
Yes,it is
- 2
How do I create those functions and attributes?