putting comments in for code
hi a while back I started to put comments on the code and now I have lost some of them, could anyone help me comment this unfinshed peice of code
Code java:
//access to the java.utill.random libary.
import java.util.Random;
/**
* Lucky dip lottery ticket system.
* @author Daniel Prempeh
* @version 1.1 2013
*/
public class Numbers
{
private int[] Lotto;
private final int MAX=6;
public Numbers()
{
Lotto = new int[MAX];
}
public void generateNums(int qty)
{
//assign random values to 6 lines of intergers.
Lotto[0] = 1 + (int) (Math.random() * 49);
Lotto[1] = 1 + (int) (Math.random() * 49);
Lotto[2] = 1 + (int) (Math.random() * 49);
Lotto[3] = 1 + (int) (Math.random() * 49);
Lotto[4] = 1 + (int) (Math.random() * 49);
Lotto[5] = 1 + (int) (Math.random() * 49);
for(int i=0;i<MAX;i++)
{
//to print the values of an array
System.out.println(Lotto[i]);
}
}
}
Re: putting comments in for code
Quote:
help me comment this unfinshed peice of code
The comments in a piece of code should come from the design for the code.
If you have defined what the code should do, add the thoughts that describe that design as comments to the code.
How can anyone comment unfinished code? The comments should reflect what the code does.
Please edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Re: putting comments in for code
my tutor was like you should start to be able to comment on your code and I did when I started this but I have lost some of it
basically it is a Numbers class should provide the following functionality:
Generates 6 random numbers in a range 1 to 49.
Write YOUR OWN custom method incorporating an algorithm to sort the numbers in ascending order.
Store the 6 numbers in a fixed-sized collection (array).
Format and display the numbers (number output in the range 1 to 9 should be preceded by a blank space).
Re: putting comments in for code
Sorry, why can't you add the comments in your last post to the code?
Re: putting comments in for code
I commented the code but lost it a long time ago and now forgot what comments to put in the code now
Re: putting comments in for code
Comments should say what the code does. If you wrote the code, do you know what you wanted the code to do and how the code was going to do that?
If you didn't write the code, then maybe you should start over: make a design for the program, make a list of the steps the code should do, add that list of steps to the code as you write it.