Raised This Month: $51 Target: $400
 12% 

Odd SourcePawn "feature"?


Post New Thread Reply   
 
Thread Tools Display Modes
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 03-26-2012 , 12:31   Re: Odd SourcePawn "feature"?
Reply With Quote #41

I seriously just got this code to work with in Java class:

PHP Code:
import java.util.Arrays;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
import static java.lang.System.*;

public class 
NumberSearchDriver
{
    public static 
void mainString args[] ) throws IOException
    
{
        
Scanner file = new Scanner(new File("NumberSearchData.txt"));  // Put file in the project folder
        
int size file.nextInt();  // Reads the first line for the number of data sets in the file
        
file.nextLine();            // Necessary to read the linefeed

        
for(int i 0i<sizei++) // Loop through each data set in the file
        
{
            
String sent file.nextLine();  // Reads the line of integer values
                   
String[] listOfNumbers sent.split(" ");    // The split method will create a String array
            
NumberSearch ns = new NumberSearch(listOfNumbers);  // Construct a new NumberSearch object
            
int findNum file.nextInt();  // Read the following line for the number to search for
                
System.out.println("Unsorted array: "+ns);        // Print unsorted array
                
ns.sortNumArray();                                // Sort the array
                
System.out.println("Sorted array:   "+ns);        // Print the sorted array

                // Print out a statement about the value in the array with the next largest value than the search number.
            // See the instructions for the format of this statement


              
file.nextLine();   // Necessary to read the linefeed
        
}
    }

__________________
Dr. McKay is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 03-27-2012 , 13:36   Re: Odd SourcePawn "feature"?
Reply With Quote #42

It's always good to know what ns.sortNumArray(); must do. A comment definitely resolves any ambiguity here!

Last edited by 11530; 03-27-2012 at 13:37.
11530 is offline
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 03-27-2012 , 17:22   Re: Odd SourcePawn "feature"?
Reply With Quote #43

Quote:
import static java.lang.System.*;
Then he goes System.out.println(). Cool story there.

Instead of writing heaps of comments these efforts could be spent on throwing in some boring checks like whether file exists and hasNextInt() for scanner. But oh who cares.
__________________

Last edited by Lord Canistra; 03-27-2012 at 17:23.
Lord Canistra is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:54.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode