bluej

while loop not ending when required

早过忘川 提交于 2019-12-02 08:19:35
So some background information, I'm new to programming and am still learning, so I apologize for my trivial error making. I am making my own text based game just to further practice etc. Here is the link to everything on dropbox for more context: https://www.dropbox.com/sh/uxy7vafzt3fwikf/B-FQ3VXfsR I am currently trying to implement the combat system for my game, and I am running into the issue of the combat sequence not ending when required. The 'combat sequence' is a while loop as follows: public void startCombat() { inCombat = true; while(inCombat != false)// && herohealth > 0 &&

How to enter a LocalDate value into BlueJ “Create Object” dialog box

这一生的挚爱 提交于 2019-12-02 08:05:19
I'm not trying to format the date in YYYY-MM-DD or dd/MM/YYYY. I'm asking about the literal format of LocalDate. I just started learning Java and I am using this IDE called BlueJ. and I want to create a test method. The screenshot will show what I am trying to do Now since from the constructor we know that it requires a int, LocalDate and a double. I've searched online and found that https://www.javabrahman.com/java-8/java-8-working-with-localdate-localtime-localdatetime-tutorial-with-examples/ java.time.LocalDate: A LocalDate instance holds a date without a time zone, in ISO-86011 calendar

Java - OR / AND characters (|| &&) illegal in if-statement

試著忘記壹切 提交于 2019-12-01 06:33:44
I am coding a simple program using a scanner and now want to make sure the user only types "yes" or "no" by comparing the input to these words. I'm using a normal if -statement with || (pipes): if (!input.equals("yes") || !input.equals("no")) { //do something } Java (I am using BlueJ) complains about my pipes, it says: " illegal character: '\u00a0' " What I tried I copied & pasted pipes from the wikipedia site to make sure I am really using correct pipe-characters restarted BlueJ tried using equal signs (&&), same error if I removed the second condition and the pipes it works Does anyone have

How do I enter parameters for an ArrayList in BlueJ?

a 夏天 提交于 2019-12-01 05:32:59
In BlueJ, if I write a method that takes an array as a parameter, then when I want to test that method with a method call I have to enter the elements with curly braces, so: {1,2,3} How do I do a method call for an ArrayList ? Here is my code: import java.util.*; public class Test2{ public static int[] toArray(ArrayList<Integer>a){ int len = a.size(); int []b = new int[len]; for(int i = 0; i<len; i++){ b[i] = a.get(i); } return b; } } Now I want to test it in BlueJ, what should I type in the following dialog box? You need to create an instance of ArrayList to pass to your method when you call

Java - OR / AND characters (|| &&) illegal in if-statement

假装没事ソ 提交于 2019-12-01 05:32:37
问题 I am coding a simple program using a scanner and now want to make sure the user only types "yes" or "no" by comparing the input to these words. I'm using a normal if -statement with || (pipes): if (!input.equals("yes") || !input.equals("no")) { //do something } Java (I am using BlueJ) complains about my pipes, it says: " illegal character: '\u00a0' " What I tried I copied & pasted pipes from the wikipedia site to make sure I am really using correct pipe-characters restarted BlueJ tried using

Is there a limit on the maximum of number of lines which can be printed to console by BlueJ?

a 夏天 提交于 2019-11-28 14:17:59
I have a simple main method which includes dozens of "System.out.print" as depicted below: public class StudentTester { public static void main() { System.out.print('\f'); System.out.println("1"); System.out.println("2"); System.out.println("3"); System.out.println("4"); System.out.println("5"); System.out.println("6"); System.out.println("7"); System.out.println("8"); System.out.println("9"); System.out.println("10"); System.out.println("11"); System.out.println("12"); System.out.println("13"); System.out.println("14"); System.out.println("15"); System.out.println("16"); System.out.println(

How to call a method function from another class?

白昼怎懂夜的黑 提交于 2019-11-27 23:16:02
I'm writing a java project that has three different classes. This is what i have have so far. I'm just stuck on how do you call a method function from another class to another class. I have written 2 classes already. I got the "Date" class and "TemperatureRange" class done; now i'm trying to call those 2 classes into "WeatherRecord" class. I'm not sure if i'm explaining this right. public class WeatherRecord //implements Record { private String TemperatureRangetoday; private String TemperatureRangenormal; private String TemperatureRangerecord; public static void main (String[] args){ } } This

Is there a limit on the maximum of number of lines which can be printed to console by BlueJ?

北城余情 提交于 2019-11-27 08:13:39
问题 I have a simple main method which includes dozens of "System.out.print" as depicted below: public class StudentTester { public static void main() { System.out.print('\f'); System.out.println("1"); System.out.println("2"); System.out.println("3"); System.out.println("4"); System.out.println("5"); System.out.println("6"); System.out.println("7"); System.out.println("8"); System.out.println("9"); System.out.println("10"); System.out.println("11"); System.out.println("12"); System.out.println("13

“int cannot be dereferenced” in Java

旧时模样 提交于 2019-11-26 22:58:05
I'm fairly new to Java and I'm using BlueJ. I keep getting this "Int cannot be dereferenced" error when trying to compile and I'm not sure what the problem is. The error is specifically happening in my if statement at the bottom, where it says "equals" is an error and "int cannot be dereferenced." Hope to get some assistance as I have no idea what to do. Thank you in advance! public class Catalog { private Item[] list; private int size; // Construct an empty catalog with the specified capacity. public Catalog(int max) { list = new Item[max]; size = 0; } // Insert a new item into the catalog. /

How to call a method function from another class?

末鹿安然 提交于 2019-11-26 21:25:24
问题 I'm writing a java project that has three different classes. This is what i have have so far. I'm just stuck on how do you call a method function from another class to another class. I have written 2 classes already. I got the "Date" class and "TemperatureRange" class done; now i'm trying to call those 2 classes into "WeatherRecord" class. I'm not sure if i'm explaining this right. public class WeatherRecord //implements Record { private String TemperatureRangetoday; private String