I have a few codes and im at the chapter of my class where im learning composition. I think this is very easy for you guys to fix but right now im having a hard time on this. Its about the code in the test src where im trying to put objects together and display the fields of an object. My System.out.println(tv.getResolution()); is giving me "section7.Resolution@1db9742" while im trying to get the 200,100 int value to display... Can anyone help me ive been stuck on this for like 2 hours and couldnt find anything on the internet. Tried to change the return types etc x.x
public class TV {
private String model;
private Resolution resolution;
public TV(String model, Resolution resolution) {
this.model = model;
this.resolution = resolution;
}
public String getModel() {
return model;
}
public Resolution getResolution() {
return resolution;
}}
\
public class Room {
private TV tv;
private Bed bed;
private Desk desk;
public Room(TV tv, Bed bed, Desk desk) {
this.tv = tv;
this.bed = bed;
this.desk = desk;
}
public void turnLightsON() {
roomLighting();
}
private void roomLighting() {
desk.lamp();
}
public void getResolution() {
this.tv.getResolution();
}
}
/
public class Resolution {
private int width;
private int height;
public Resolution(int width, int height) {
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}}
/
public class Test {
public static void main(String[] args) {
Bed bed = new Bed(100, 250, "LaBed");
Desk desk = new Desk(110,175,"Black");
Resolution resolution = new Resolution(200,100);
TV tv = new TV("Samsung", resolution);
Room room = new Room(tv,bed,desk);
room.turnLightsON();
System.out.println(tv.getResolution());
System.out.println(tv.getModel()); }}