Hello programmers! I am working on a Tic-Tac-Toe player vs. computer class, which is supposed to have a `run.()` method in order for the game to start. In a `gameWon()` member function, I am checking for a win, either by the player or by the computer. I check to see if a row was won, if a column was won, and if a diagonal was won. With each scenario, a private member function is called that returns a `bool`. In my `diagonalWon()` function, I check to see if I have an equal number of rows and columns, which means that …

Member Avatar
Member Avatar
+0 forum 8

Hello. I uhh... I just want a sample code for the Exceptions: SecurityException and StackOverflowException. I'm still new to handling exceptions. Please, just a sample code that is about those two will do.

Member Avatar
Member Avatar
+0 forum 2

whats wrong with this code? It keeps giving me an "unreachable code detected " exception public static int search(string Registration) { // this method will search for registration, if found it will return the index value , else it will return max value + 1 for (int x = 0; x < numOfRowsCars; x++) { reg = ds1.Tables["tblCars"].Rows[x][2].ToString(); MessageBox.Show(reg); if (Registration == reg) { // Then return the index of the registration number return x; } else { // Then return the max index + 1 return numOfRowsCars; } } }

Member Avatar
Member Avatar
+0 forum 3

i created a testScores class which initialized an object with an array of scores and had an exception that if the score was <0 or >100 it would throw an IllegalArguementException. I got my main program to work it throws the exception for the array with the bad grade in it and it gives me the correct average for the array with al the good grades. My question is how do i print the position of the element in the array that the bad grade is and print the grade that threw the exception as well?? testScores class: public class …

Member Avatar
Member Avatar
+0 forum 2

http://ideone.com/XRMOPI line 43 is throwing this exception and i can't figure out why //Exception in thread "main" java.util.InputMismatchException //at java.util.Scanner.throwFor(Unknown Source) //at java.util.Scanner.next(Unknown Source) //at java.util.Scanner.nextDouble(Unknown Source) //at TestC.getBusinessInfo(TestC.java:50) //at TestC.main(TestC.java:29) any help is very much appreciated

Member Avatar
Member Avatar
+0 forum 1

I wanted to convert this segment of code into something slightly different package expression; import java.util.*; public class Expression{ /* * Strings used for storing expression. */ String s, x; /* * Term evaluator for number literals. */ double term(){ double ans = 0; StringBuffer temp = new StringBuffer(); while( s.length() > 0 && Character.isDigit( s.charAt( 0 ) ) ){ temp.append(Integer.parseInt( "" + s.charAt( 0 ) )); s = s.substring( 1 ); } if( s.length() > 0 && s.charAt( 0 ) == '.' ){ temp.append( '.' ); s = s.substring( 1 ); while( s.length() > 0 && Character.isDigit( s.charAt( 0 …

Member Avatar
Member Avatar
+0 forum 5

While lunching the application in TOMCAT 5.5 and JDK 1.5 I am getting below exception could some help me in resolving the issue Jul 25, 2012 4:12:50 AM org.apache.catalina.core.ApplicationDispatcher invoke SEVERE: Servlet.service() for servlet jsp threw exception java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V at org.apache.jasper.compiler.TagLibraryInfoImpl.createAttribute(TagLibraryInfoImpl.java:572) at org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:401) at org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248) at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:162) at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:418) at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483) at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1543) at org.apache.jasper.compiler.Parser.parse(Parser.java:126) at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211) at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100) at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:146) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) at org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1058) at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:451) at org.apache.struts.action.RequestProcessor.processActionForward(RequestProcessor.java:401) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1420) at …

Member Avatar
Member Avatar
+0 forum 1

i am new to android. While i am running my application, it is running well in landscape mode, but in portrait mode, application is forcefully closed giving the following in log 05-31 16:48:30.958: W/KeyCharacterMap(428): No keyboard for id 0 05-31 16:48:30.958: W/KeyCharacterMap(428): Using default keymap: /system/usr/keychars/qwerty.kcm.bin 05-31 16:50:45.728: D/AndroidRuntime(484): Shutting down VM 05-31 16:50:45.728: W/dalvikvm(484): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 05-31 16:50:45.758: E/AndroidRuntime(484): FATAL EXCEPTION: main 05-31 16:50:45.758: E/AndroidRuntime(484): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kalmas/com.kalmas.Kalma2}: java.lang.NullPointerException 05-31 16:50:45.758: E/AndroidRuntime(484): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 05-31 16:50:45.758: E/AndroidRuntime(484): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 05-31 16:50:45.758: E/AndroidRuntime(484): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 05-31 16:50:45.758: E/AndroidRuntime(484): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 05-31 16:50:45.758: …

Member Avatar
Member Avatar
+0 forum 1

I’m creating a program that displays random lines from a file. I have 8 lines on my text file and after displaying the last/8th random line… it displays [B][I]Segmentation fault[/I][/B] and then terminates the program. The program should display a message saying that there are no lines left to display. Can someone help me with this? Or can somebody tell me how to display the 8 lines only? This is the function I made so far… [CODE]int easy() { vector<string> text_file; string quest; char choice; int line_counter = 1; srand(time(NULL)); ifstream myfile ("./questions/easy.txt"); cout << "Welcome to EASY level category!\n" …

Member Avatar
Member Avatar
+0 forum 5

Can anyone help me with this? or alter the code of mine when it comes to the user Input here's the block of code of mine [CODE]public int Remove(int i, Briefcase c[], String[] m) { int nChoice = 0; System.out.print("\tPlease remove " + i + " cases: "); nChoice = input.nextInt(); if (c[nChoice] == null) { System.out.println(); System.out .println("\tYou already entered that digit choose again\n"); Remove(i, c, m); } else { System.out.println("\tI'm " + m[nChoice] + " You just removed case # " + nChoice); System.out.println("\t|" + nChoice + "| contains $" + c[nChoice].getAmount() + "\n"); } return nChoice; }[/CODE] …

Member Avatar
Member Avatar
+0 forum 29

[B]Hi Guys[/B] Please Help me out....Iam banging my head to the wall now just because of this problem.... I want to get the HTML code of a Website using the Class of HttpWebRequst and HttpWebResponse..... the main problem is that whatever web requests are made...they are done using Internet Explorer.....Please tell me a way that how can I send HttpWebRequests via Mozilla Firefox.... The Exact issue is that for a certain URL the Internet Explorer shows page cannot be displayed because it has a 500 internal server error....same Error code occurs in Mozilla Firefox but it does show some html …

Member Avatar
Member Avatar
+0 forum 1

OK I have a project due tonight at midnight and I know I should have posted sooner but it seemed like such simple things that I just knew I could do it on my own. I was wrong. I need your help. I have a program that essentially makes a database in the console by asking the user for names and stats of various sports players. It saves them to a txt file, sorts them, removes them and averages the stats. No problems there. The problems I am having are that I am supposed to do error detection using exception …

Member Avatar
Member Avatar
+0 forum 12

What i'm trying to do here is just place the values in my text file into variables the txt file contains: 1111 50 2222 60 3333 70 4444 80 5555 90 i get the error :[COLOR="red"]Exception in thread "main" java.lang.NullPointerException at udptry2.m.readfiless(m.java:41) at udptry2.m.main(m.java:68)[/COLOR] [CODE] package udptry2; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.IOException; /** * * @author JAY THE KIDD */ public class m { BufferedReader in; BufferedWriter out; int a; String[] id; String[] result; public void openfile() { try{ FileReader inputFile = new FileReader("serverdata.txt"); in = new BufferedReader(inputFile); }catch(Exception e) { System.out.println(e +"File not found"); }//end of …

Member Avatar
Member Avatar
+0 forum 6

I'm having trouble figuring out how to use exceptions to check if a file stream was created successfully. I know I can use if statements, but how do I do this using try/catch statements? It compiles successfully but it gives me an error when I supply a non-existent filename as an argument. If I supply a file that does exist, it runs fine. The message I get when I give it a bogus filename is: [code] terminate called after throwing an instance of 'char*' Abort trap [/code] [code=cpp] #include <iostream> #include <fstream> #include <exception> int main(int argc, char *argv[]) { …

Member Avatar
Member Avatar
+0 forum 2

Hi Guys, I'm currently developing a project using WCF (hosted on local IIS) which connects to a local SQL database using LINQ to get data. My problem is that when I run the code, 9/10 times it'll fail with the "Specified Cast Is Not Valid" error, but the other 1/10 times it will return the correct value (a messagebox with the records 'name' field. The code snippets below are from my wcf datacontract/servicecontract, server and client code. There is only one record in the table im retrieving. WCF Service (IFaveoService.cs) [CODE][ServiceContract] [ServiceKnownType(typeof(SRType))] public interface IFaveoService { [OperationContract] IEnumerable<SRType> GetSRTypeByID(int srID); …

Member Avatar
Member Avatar
+0 forum 10

I am getting System.IndexOutOfRangeException everytime I try to compile my program. This is where the error is happening. [CODE] public static string findlinks2(string source) { char quotes = (char)34; //sets the char variable to quotes since you can't use it in a string normally string searchstring = (quotes + "fmt_url_map" + quotes + ":" + quotes); //sets the searchstring to "fmt_url_map": string[] fmt1 = System.Text.RegularExpressions.Regex.Split(source, searchstring); //splits html into 2 arrays string fmt2 = fmt1[1].ToString(); [/CODE] The error is occuring when is trys to assign the variable fmt2 the contents of fmt[1].ToString();. The error is obviously because the array fmt[1] …

Member Avatar
Member Avatar
+0 forum 2

I have implemented a catch statement for both the InputMismatchException and the ArithmeticException, how come they are not working? Also, if the user enters "quit" for the numerator, the program should be able to exit. But my understanding is that as soon as the user enters something that is not an integer, the program goes to catch the exception. So, how can the "quit" option be included here? The below is my program. Thanks! [CODE]import java.util.InputMismatchException; import java.util.Scanner; /** * */ /** * @author cathy * */ public class IntegerDivision { /** * @param args */ static double result; public …

Member Avatar
Member Avatar
+0 forum 9

I am writing a program that creates a file and attaches it to an email. I use a loop to create the attachment, send the email and then do it again with different information in the attachment. This works well for one tim through the loop, but on the second time through I get an error when I try to open the file for output to create the new version of the file. I get an unhandled exception of "The process cannot access the file 'c:\Project\Articles1\Article.txt' because it is being used by another process.". How can I release the file …

Member Avatar
Member Avatar
+0 forum 2

I have spent over a WEEK trying to figure out why my code isn't working. It's a long code, I will post it all but I will break down the code as I explain. First off, I have called double[] arrays and then initialized them later on in the program on certain steps. What problem is that even though they are initialized, later on in the code, it's telling me that the double[] I'm requesting is NULL, as if it didn't know that I have already done all that and added elements to it. Here's the program..... [code] package usefulapps; …

Member Avatar
Member Avatar
+0 forum 2

using exception try, catch and finally derive a program that accepts any 10 letter string. if the string is greater than 10, display an error message; if string has no vowel display an error message else display only all vowels. can u help me for the java code of this program? plss....

Member Avatar
Member Avatar
+0 forum 3

Hi, In C#, i got sql Exception which consists of 2 lines. I need only the 2nd line of that Exception only. Ex: The transaction ended in the trigger. Table Validation failed - Name: x; Condition: m!=0 i need "Table Validation failed - Name: x; Condition: m!=0" only. I have tried e.LineNumber but it not works well. Can anyone help me?

Member Avatar
Member Avatar
+0 forum 2

Hi , these days I'm reading the brans kernel development tutorial. and doing it's particles. So last I find to had to read Intel 80386 programmers manual by intel. In section 2.6 Interrupts and Exceptions I asking a theoretical question here. They said Exceptions are synchronous and Interrupts are asynchronous. what that means precisely ? Is that mean's that interrupt even can be happen middle of a instruction , but exceptions can't happen like that ? Please correct me if I'm wrong.

Member Avatar
Member Avatar
+0 forum 3

The End.