Hi guys, I seem to have an issue with a boolean method returining a value. Here is the code excerpt - irrelevant code omitted: public class StreamsTest { public static void main(String[] args) { String[] arr = new String[]{"a", "b", "c"}; //convert array to string with streams List<String> list = Arrays.stream(arr).collect(Collectors.toList()); isElementInIt(list); } static boolean isElementInIt(List<String> list) { if(list.isEmpty()) { return false; } else { for (String string : list) { if (string.contains("a")) { return true; } else { return false; } } } } } STS says that the isElementInIt method should return a boolean value, but it's already …

Member Avatar
Member Avatar
+0 forum 2

I have the following code and i dont understand why P4(3,7)is giving returnvalue true (1) , since here 7(ConTemp.XYCoord[1]) is bigger than 5 (ReCoordRo.XYCoord[1]), so i would like to know a way to monitor the boolean Rechteck1.contains(P4), watch windows doesnt give me that option, so how do i go about it ? Thx #include <iostream> #include <array> using namespace std; class Punkt { public: int XYCoord [2]={}; void setupCoord (int x, int y){ XYCoord[0]=x; XYCoord[1]=y; } }; class Rechteck { public: Punkt ReCoordLu,ReCoordRo; double flaeche(double x, double y){ double xy=x*y; return xy; } bool contains ( Punkt &p){ Punkt *ConTemp1=&p; …

Member Avatar
Member Avatar
+0 forum 2

I need a boolean to be stored with a String (or possibly a Path, not sure which one I want to use yet). I thought about using a Map, so I did some looking around and found out that LinkedHashMaps are the only type of Map that stay in Order when you do something with them. I could use two arrays, but I'm sure theres something better to use. Usually I would just make a helper class that stores the String, or Path, and the boolean and make Objects of this class. I know I could do this, but what's …

Member Avatar
Member Avatar
+0 forum 12

I have the following struct definition: struct finfo { string filename; long fsize; bool operator() (finfo i, finfo j){return (i.fsize > j.fsize);} } fstruct; And the following vector definition: vector<finfo> fdata; In the code I use the following statement to sort the vector elements by fsize: sort(fdata.begin(),fdata.end(),fstruct); This works perfectly well, but how can I sort by the field "filename" when i.fsize = j.fsize ? (The vector is filled by reading directory information, and putting the filenames and filesizes in the appropriate fields in the struct. If the filesize is equal I want to sort the files alphabetically by file …

Member Avatar
Member Avatar
+0 forum 3

i want to understand that what is bolean data type in c++. I tried to my best but i can not understand boolean data type plz help me

Member Avatar
Member Avatar
+0 forum 1

i have a database at the links. so the problem it still insert between the time some friends suggested to loop all the data 1st then validate but im confused here. **any help would be great ** <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <?php mysql_connect("localhost","root",""); mysql_select_db("windsor_reservation"); if(isset($_POST['reserve'])){ echo $stime = ($_POST['stime']); echo '----'; echo $etime = ($_POST['etime']); echo '<br>'; $chk = false; $date = date("Y-m-d"); if($stime < $etime){ $q = mysql_query("SELECT * FROM time WHERE `date`='$date' AND `stime`>='$stime' AND `etime`<='$etime'"); $count = mysql_num_rows($q); if($count > 0){ echo 'Time already taken choose another time please'; }else{ …

Member Avatar
Member Avatar
+0 forum 4

I am having trouble adding an item that will increase a player's energy in my BlueJ game. At the bottom of the createRooms() method in my game class I have added several items to rooms. At that point I tried setting boolean newEnergy equal to true. If the player types "use", they will receive 10 energy if boolean newEnergy is equal to true. I am not sure how I would set boolean newEnergy to true only when the energy item is still in the room. /** * Create all the rooms and link their exits together. */ private void createRooms() …

Member Avatar
Member Avatar
+0 forum 2

I need help reading a bool function from my HW assignment, I am not asking you to do complete my assignment for me. All I need help with is reading my bool function in main. Thank you for looking #include<iostream> #include<fstream> #include<string> using namespace std; struct StudentType {string studentName; int testScore;//Between 0 and 100 char grade; }; void PrintNameHeader(ostream& out); bool OpenInputFile(ifstream& inFile, string& infilename ); void Pause(); void ReadStudentData(ifstream& infile, StudentType student[], int& ); void AssignGrades(StudentType student[], int); int HighestScore(const StudentType student[], int ); void PrintNamesWithHighestScore(const StudentType student[], int); void DisplayAllStudents(const StudentType student[], int); void GetLowHighRangeValues(int& , int&); void …

Member Avatar
Member Avatar
+0 forum 5

Pk, so here's the code I'm running for a checkboxlist object public void regSubjects(object sender, EventArgs e) { int courseCount = 0; for (int i = 0; i < coursesFound.Items.Count; i++) { if (coursesFound.Item[i].Selected) coursesCount++; } if ((courses < 4) && (courses > 6)) clabel.Text = string.Format("Choose between 4 - 6 subjects"); } Wierd thing is, if have only one condition in my final if, it works fine, if i have both, it doesn't pick it up, even if I nest the two conditions in their own if, it doesn't pick up on the error, just ignores it. Viusal Studio …

Member Avatar
Member Avatar
+0 forum 7

basically i am working on a project for uni, which is to create a form of an abacus model. - peg_array[] stores the number of counters/beads present in each of the pegs(lines) of the abacus. i am trying to use 2 boolean methods: "boolean removeCounter(int thisPeg)" "boolean removeCounter(int thisPeg)" thisPeg - An integer that refgers to any of the pegs in the abacus Please can someone help me solve this? All i am trying to do is to recognise where possible errors may occur and prevent them from happening. E.G. if conditions are true then add one counter to the …

Member Avatar
Member Avatar
+0 forum 6

Consider this: I have a user-defined stored procedure which returns a bit value as OUTPUT. In my calling code I want to check that value. I define it in my code as follows: Dim retval As New SqlParameter() retval.ParameterName = "@return" retval.SqlDbType = SqlDbType.Bit retval.Direction = ParameterDirection.Output DataCommand.Parameters.Add(retval) DataCommand.ExecuteNonQuery() ' now check the return value If Not (CBool(retval.Value)) Then Throw New ApplicationException("SQL returned FALSE. ") End If Which appears to get the desired results, in that my code hits the If statement and continues. However, if I change the If statement to `If Not (CBool(retval.SqlValue)) ...` I get an exception …

Member Avatar
Member Avatar
+0 forum 4

Good morning I have an event called "OptionChanged" that is triggered when one of many CheckBox's is changed. string cb = ((CheckBox)sender).Name.Remove(((CheckBox)sender).Name.Count() - 1); gets the name of the changed CheckBox, removes the last letter then copies it to a string. Now, i need to find the relevant bool (named exactly like the string) that has already been declared to change its value. Is this possible? Thanks

Member Avatar
Member Avatar
+0 forum 4

Boolean eminem = new Boolean("yes"); What does it mean & what does it create? Thanks.

Member Avatar
Member Avatar
+0 forum 2

I am trying to implement a function sameMonth from a class to compare two user entered months. My class is declared in a header file "Date.h": #include <iostream> using namespace std; class Date { private: string month; int day; int year; public: Date(); Date(string aMonth, int aDay, int aYear); void setMonth(string month); void setDay(int aDay); void setYear(int aYear); string getMonth(); int getDay(); int getYear(); void printDate(); bool sameMonth(string aMonth, string aMonth2); }; The function sameMonth itself exists in another file "Date.cpp" bool sameMonth(string aMonth, string aMonth2) { if (aMonth == aMonth2) { cout << "The two months entered are the …

Member Avatar
Member Avatar
+0 forum 1

Hello, I am hoping someone can help me understand a piece of code i found. Since php is not my primary language, and what i googled returned vague results, i am unsure exactly how a number or integer value can be used directly as a boolean in a while operation. function testfunction( $testparam ) { if( $testparam > 0x3F3F3FFF ) { $testparam &= 0x3F3F3FFF; } do { $testparam >>= 6; }while($testparam); } Basically i need to be able to understand the logic of the while loop here, does it check it testparam is > 0 and evaluate that as true …

Member Avatar
Member Avatar
+0 forum 1

Hello, I'm trying to make a very basic + - calculator in java using constructors after watching thenewboston video tutorial I tried to experiment with it. My litle project is almost finished my only problem is that the boolean I use is being reset after I assign it. If someone could take a look at I would really appriciate it. Also ignore the names of the class didn't bother to change it after the tutorial video. package bucky; public class tuna { private double num1; private double num2; private double awnser; public boolean plus; public tuna(double numbr1,double numbr2){ num1 = …

Member Avatar
Member Avatar
+0 forum 2

Does anyone know a good way to force javascript to evaluate all operands in a boolean expression? In particular, what I am tring to do is essentially this: return isValid(a) && isValid(b) && isValid(c); while this technically does work, the function is responsible for highlighting invalid areas on the form for user attention. Since the `&&` operator short circuits, it will only ever highlight the first invalid expression, possibly requiring the user to go through several rounds of correcting input data. Any ideas?

Member Avatar
Member Avatar
+0 forum 2

The assignment requires program to read from a file into an array, use two boolean functions to validate certain data (set to "true" when there are no errors) then output any errors to a separate file. Everything works fine except for validating the rate. All the numbers are read into the array correctly and the calculation seems sound (works correctly on a calculator) but for some reason the calculation in C++ always results in 0 which makes EVERY record output an error. PLEASE HELP, it is driving me CRAZY :twisted: (the "cout" lines were inserted just so I could see …

Member Avatar
Member Avatar
+0 forum 4

[CODE]class Date { private int day, month, year; // the date Date(int d, int m, int y){ day = d; month = m; year = y; } Date(){ }; void get() { day = Console.readInt(); month = Console.readInt(); year = Console.readInt(); } void put(){ System.out.println(day + "/" + month + "/" + year); private int elapsedDays() { // The number of days elapsed from 1/1/1900 to this date int days = (year-1900)*365+(year-1901)/4; int k = 1; while (k<month) { int daysInMonth; if (k==9||k==4||k==6||k==11) daysInMonth = 30; else if (k==2) { if (year%4==0 && year!=1900) daysInMonth = 29; else daysInMonth = …

Member Avatar
Member Avatar
+0 forum 5

Hi this is my first post, but I've lurked for a while usually finding answers to my questions in other threads, I couldn't find this one so I broke my posting cherry to ask. I know I'm missing something, probably really simple, but possibly I'm doing this completely wrong. I'm trying to write a method that determines if a year is a leap year and then returns it to main to print out whether it's a leap year or not, after I get this working I'm going to modify it so that it runs in a loop until the user …

Member Avatar
Member Avatar
+0 forum 5

print "Hello, World!" ;) Hi, everyone, Venku (a.k.a Python Newb) here. I just kind of randomly opened up Python today (I do that a lot), and I decided I would finally ask this: What does the "is" statement do in Python 2.7.1 (if the ver# matters)? I checked out the Python command line (used "help()" "modules" "is"), but it only gave a comparison to C and an unintelligible description of what it does. I have an extensive vocabulary, and I am great with grammar and spelling, but the [I]terminology,[/I] like "collection" and "membership" confused me. It appears to be used …

Member Avatar
Member Avatar
+0 forum 3

I am currently writing a program in which you input a word and the program then outputs all of the different ways the characters can be moved round into anagrams. I have wrote a way of turning the command line argument into a char array using the toCharArray() now I need to write a boolean array to see if the character has been used before. Any help?

Member Avatar
Member Avatar
+0 forum 6

i have this code, i need to have [B]for()[/B] inside this boolean method, but it shows an error that return method is missing. how can i solve it? [CODE] public static boolean findPrevious(int dataIdx, int featIdx, String data, String[][] array){ for(int i=0; i<dataIdx; i++) { if(array[i][featIdx] == data) return false; else return true; } } [/CODE] thanks ^^

Member Avatar
Member Avatar
+0 forum 6

[B]Edit: that was my mistake. i placed the codes in wrong line. i solved it by myself already. thanks for viewing.[/B]

Member Avatar
Member Avatar
+0 forum 3

The last time I was making a program, I wanted to input from user a boolean answer (to save space ;)) An input of 0/1 works good (0-false) and (1-true), but if the user inputs the boolean values as "true" and "false", it comes out to be an error. So, are there any ways of doing so.? I believe, that the strings "true" and "false" are defines using #define in the header files because of which the input is creating an error. Am i correct.?

Member Avatar
Member Avatar
+0 forum 5

[CODE]a.cpp: In function ‘int main()’: a.cpp:39: error: no matching function for call to ‘find(int&, int)’ [/CODE] [CODE]#include <iostream> #include <fstream> using namespace std; int minutes, seconds; char temp; int array_l; bool* sees; int* a; int saade; int main() { ifstream sisf("raadio.sis"); ofstream valf("raadio.val"); /* * How many songs? */ sisf >> array_l; int a[array_l]; /* * Read info and putting info in array */ for (int i = 0; i < array_l; i++) { sisf >> minutes >> temp >> seconds; a[i] = 60 * minutes + seconds; cout << a[i] << endl; } sisf >> minutes >> temp >> …

Member Avatar
Member Avatar
+0 forum 5

Hey guys, So, I need to add booleans on my project for the final piece. I have all of it done but the booleans. Basically, I checked about 10+ links on google, and none of them really explained how to do booleans. So, what I need is something that does this: [CODE]if (paybackYears <= TEN) { boolean buyIt = true; System.out.println("Therefor, the likelyhood of you making your money back in 10 years is " + buyIt"."); } else { System.out.println("Therfore, the likelyhood of you making your money back in 10 years is " + buyIt+"."); } [/CODE] I know this …

Member Avatar
Member Avatar
+0 forum 8

hey there guys, just starting to learn java and i'm having a little trouble putting code to paper. don't really want to ask the teacher because hes a perv but lets not get into that. okay, i am supposed to make a GUI for electronic voting ballot paper thingy and i made something i think is cool with netbeans ive done everything so far up until the submit button i'm thinking i have to use some kind of array for it but i'm not sure how to apply it the array is supposed to be an error doodad for certain …

Member Avatar
Member Avatar
+0 forum 1

Never mind, my bad, I figured it out. :P

Member Avatar
Member Avatar
+0 forum 1

Is this: A)[CODE]while (!isLegal(move, board))[/CODE] the same thing as: B)[CODE]while (isLegal(move,board) = !!)[/CODE] ?

Member Avatar
Member Avatar
+0 forum 5

The End.