Basically, the project I'm working on this week is to make a school lunch menu with a GUI, when the person types in a day, the menu for that day shows up. We have two files, ones a day off text file which just has the days off in it, and the other is a lunch menu file, which each line being an entry. Each day inside that lunch menu file ends with the word Milk. I've been trying to get the days off from the file and store it into an array of int, but every time i System.out.prin t the array.... it gives me gibberish. Can you guys help me with this (and any other issues you see in the program). I'd greatly appreciate it because I've been looking at this for awhile and am really stuck.
From just trying to run the getDaysOff method, this is what i get in the console...
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
Code:
import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
public class SchoolLunch implements StringLogInterface{
private int[] indexArray = new int[31];
private static Scanner input;
private static PrintWriter output;
private void getDaysOff(){
int line = 0;
try{
FileReader reader1 = new FileReader("days_off.dat");
input = new Scanner(reader1);
while(input.hasNextInt()){
line = input.nextInt();
System.out.println(indexArray);
}
indexArray[line]++;
}catch(FileNotFoundException e){
System.out.print("The file could not be found.");
e.printStackTrace();
}
}
private void buildMenu(){
int menuentry = 1;
String names = "a";
try{
FileReader reader2 = new FileReader("lunches.dat");
input = new Scanner(reader2);
ArrayStringLog log1 = new ArrayStringLog("Day" + " " + menuentry);
while(input.hasNext() && !names.contains("Milk")){
names = input.nextLine();
log1.insert(names);
log1.isFull();
log1.size();
menuentry++;
log1.getName();
log1.toString();
}
System.out.print(log1);
}catch(FileNotFoundException e){
System.out.print("The file could not be found.");
e.printStackTrace();
}
}
private boolean isDayOff(int n){
int line2 = 0;
try{
FileReader reader1 = new FileReader("days_off.txt");
input = new Scanner(reader1);
while(input.hasNext()){
line2 = input.nextInt();
}
}catch(FileNotFoundException e){
System.out.print("The file could not be found.");
e.printStackTrace();
}
if(line2 == n)
return true;
else
return false;
}
private void getMenu(int k){
indexArray[k]++;
}
public static void main(String[] args) {
SchoolLunch sl = new SchoolLunch();
sl.getDaysOff();
}
}
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
[I@fd13b5
Comment