Lecture 72 Challenge
Lecture 72 Challenge
// We haven't covered I/O yet, so your method should just print the values to the
screen.
// Also in the Main class, write a method that restores the values to a Saveable
object
// e.g. calls the method from the interface for populating fields (see above).
// Again, we are not going to use Java file I/O; instead use the readValues()
method below to
// simulate getting values from a file – this allows you to type as many values as
your class
// requires, and returns an ArrayList.
// There is a whole Java I/O section later in the course where you will get to use
files, etc.
while (!quit) {
System.out.print("Choose an option: ");
int choice = scanner.nextInt();
scanner.nextLine();
switch (choice) {
case 0:
quit = true;
break;
case 1:
System.out.print("Enter a string: ");
String stringInput = scanner.nextLine();
values.add(index, stringInput);
index++;
break;
}
}
return values;
}