The code given is all i have I was given a case file called Room.class that is used to make the exaple output
#I'm very new to java and I've gotten my first assignment and I'm very lost.
21 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @brittle bobcat! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Sorry never mind i read the rules just now ill just take an F
I just need help doing it not asking for the answer to be give just need an understanding
mainly how to continue the code she told me that i dont have to do thisSystem.out.print("Enter the number of walls: ");
int numWalls = scanner.nextInt();
room.setNumWalls(numWalls);
because of the case file
thats what i honestly dont understand
You do need to do that, though, since the Room class doesn't have any methods that take user input
The task is basically to create a Room instance, which you have already done, then ask the user for input, store that input into the room (using its setters), then output the room's field data (using its getters)
It says to ask for input in the driver directions, too
ok ig i get it if not ill be alright
Cool beans. Lmk if you have any other questions
how do i input code into text so i can ask you if this is correct
import java.util.Scanner;
public class RoomDriver {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Create a new Room object
Room myRoom = new Room();
// Ask the user for the room details
System.out.print("Enter the number of walls: ");
int walls = input.nextInt();
myRoom.setNumWalls(walls);
System.out.print("Enter the number of windows: ");
int windows = input.nextInt();
myRoom.setNumWindows(windows);
input.nextLine(); // Consume the newline character
System.out.print("Enter the wall color: ");
String color = input.nextLine();
myRoom.setWallColor(color);
// Ask the user for the furniture details
System.out.println("Enter the furniture in the room (press enter to skip):");
for (int i = 1; i <= 3; i++) {
System.out.print(i + ". ");
String furniture = input.nextLine();
if (!furniture.equals("")) {
myRoom.addFurnitureItem(furniture);
} else {
break;
}
}
// Display the room information and furniture
System.out.println();
myRoom.displayRoomInfo();
myRoom.displayFurniture();
}
}