Skip to content

Commit

Permalink
ERROR in get_num() fixed, beginning get_img()
Browse files Browse the repository at this point in the history
  • Loading branch information
g3bryja committed Feb 14, 2019
1 parent dd15f0e commit 5f41102
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
11 changes: 6 additions & 5 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
22 changes: 15 additions & 7 deletions src/com/github/book_folding_app/BookFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ public class BookFolder {
private short tolerance;
private Scanner scanner = new Scanner(System.in);

//get_image()
// Retrieves specified image as a 2D array of greyscale pixels
private int[][] get_img() {

}

// Gets string input from user
private String get_str(String message) {
Expand All @@ -30,11 +33,13 @@ private float get_num(String message, float min, float max) {
if (num >= min && num <= max) {
break;
} else {
System.out.format("ERROR: Input must be between %.4f and %.4f\n", min, max);
System.out.format("ERROR: Input must be between %.4f and %.4f", min, max);
scanner.next();
}
}
else {
System.out.println("ERROR: Input must be a number\n");
System.out.println("ERROR: Input must be a number");
scanner.next();
}
}
return num;
Expand All @@ -50,11 +55,13 @@ private short get_num(String message, short min, short max) {
if (num >= min && num <= max) {
break;
} else {
System.out.format("ERROR: Input must be between %d and %d\n", min, max);
System.out.format("ERROR: Input must be between %d and %d", min, max);
scanner.next();
}
}
else {
System.out.println("ERROR: Input must be a number\n");
System.out.println("ERROR: Input must be a number");
scanner.next();
}
}
return num;
Expand Down Expand Up @@ -99,9 +106,10 @@ private float get_height(float num, float px_height, float height) {
private void run() {
// Get dimensions from user input
img_name = get_str("\nEnter filename of image\n" +
" This image should be black--and-white only\n");
" This image should be black--and-white only\n" +
" And must be in the current directory\n");
height = get_num("\nEnter page height in inches\n",
0, Float.MAX_VALUE);
0, Float.MAX_VALUE); // Change this from MAX_VALUE to something reasonably big
num_pages = get_num("\nEnter number of pages in book\n" +
" Numbered pages (with different numbers on front and back) will count as a single page\n" +
" Be sure to include non-numbered pages\n", 0, Float.MAX_VALUE);
Expand Down

0 comments on commit 5f41102

Please sign in to comment.