• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java programming contest

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are conducting a java programming competition and we are going to eliminate the participants on the basis of number of lines of code.
But we have a problem how to count the number of lines.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are serious, I think you are barking up the wrong tree because lines of code are not an indication of correctness or quality of code (unless, of course, short/long code is the purpose of the exercise).
In any case, how about showing some effort? Do you know how to read files? Keep a counter? What exactly don't you need help with?
 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you might want to do is create a program similar to a tokenizer/syntax analyzer that:

0) Given an input file (the program you are counting)
1) eliminate comments
2) count constructs like method declarations, blocks like for-loop, semicolons that terminates statements (e.g. those inside for loop are not counted)

You would therefore need to learn all constructs allowed in your competition, e.g. inner classes.
 
Jigar Gandhi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the reply it helped but my friend Joe Ess says that the quality of the program does not depend upon the lines of code. then being a student and conducting competition for students then tell me the unbiased method to judge a code( actually we can judge but we do not want to get in argument with the participants who are hungry for the prize).
Is there any standard method.
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by JIGAR GANDHI:
Thank you for the reply it helped but my friend Joe Ess says that the quality of the program does not depend upon the lines of code. then being a student and conducting competition for students then tell me the unbiased method to judge a code( actually we can judge but we do not want to get in argument with the participants who are hungry for the prize).
Is there any standard method.



Yes, there are good ones you can do.

Here's one.

Require the solution to be in a format, such that, you can automatically test his solution by passing it to you test program.

If all of them have correct solutions, then you can base it on who finished first.

You can also specify which java statements, classes, etc. are allowed.

For example, the solution must 'implement' an 'interface' that you provided.

You simply create a test program that tests his solution, as you know the interface. Test it on all scenarios to see that his solution is correct.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just in case you're curious anyway about the NCSS (non-commenting source statements) of a piece of code -which is really what you want to count, not LOC-, look for the JavaNCSS library.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ACM sponsors programming contests for college students. You could look at their rules and problem sets and see if they are a good match. They use a setup similar to what Jesus proposes and the winner is the team that solves the most problems in the given time (ties are broken by times).
 
Jigar Gandhi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The method of counting lines through JavaNCSS library is a bit complicated you people being infallible software programmers since ages may be doing something more easier to count the number of lines in your project. Can I know what you people do to count the non commenting source statements. If using a tool can i get to access the tool or is their any easy way to count the lines by any java API classes .
please help!!
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The advice given to you above, from different members, already constitute the simplest, most efficient, and realistic clues on how you can proceed on your problem.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you really shouldn't conduct the exam.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you really shouldn't wake the zombies.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic