Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Present the cooked potatoe directly to the consumer #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
Copy link

@bigfoot547 bigfoot547 Dec 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add .settings to the .gitignore.

31 changes: 29 additions & 2 deletions src/main/java/org/drtshock/Potato.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package org.drtshock;

import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.drtshock.NotDeliciousReason;
import org.drtshock.Tuber;
import org.drtshock.NotDeliciousException;
import org.drtshock.BurntException;
/**
* A delicious tuber that is eaten by various peoples all over the world.
*/
Expand All @@ -18,11 +25,31 @@ public static void main(String[] args) {
try {
potato.prepare();
System.out.println("Of course Potato is prepared and delicious.");
} catch (NotDeliciousException e) {
potato.servePotato();
}
catch (NotDeliciousException e) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the style of this catch as well.

System.err.println("Fatal error! How could Potato not be delicious?\nReason: " + e.getReason());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
System.err.println("Fatal error! How could Potato not be delicious?\nReason: " + e.getReason());
System.err.println("Fatal error! How could Potato not be delicious?");
System.err.println("Reason: " + e.getReason());

}
}

/**Retrieves potatoe from oven and presents it to the consumer
*
* @return void
*/
public void servePotato() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code style of this method is discordant with the rest of the project.

try {
String localDir = System.getProperty("user.dir");
String[] potatoes = {"GLaDOS.jpg","lovethepotatoe.jpg","sourcream.png"};
Random myRandom = new Random();
File f = new File(localDir+"/src/main/resources/"+potatoes[Math.abs(myRandom.nextInt()%potatoes.length)]);
Desktop dt = Desktop.getDesktop();
dt.open(f);
System.out.println("Done.");
}
catch (IOException ex) {
System.out.print("whoops");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more explanatory messages would do well here.

}

}
/**
* Gets the condiments on this potato.
*
Expand Down