Skip to content

Random class#8

Open
adilzhanshukenov wants to merge 7 commits intoELTE-Soft:masterfrom
adilzhanshukenov:master
Open

Random class#8
adilzhanshukenov wants to merge 7 commits intoELTE-Soft:masterfrom
adilzhanshukenov:master

Conversation

@adilzhanshukenov
Copy link
Copy Markdown

No description provided.

@adilzhanshukenov
Copy link
Copy Markdown
Author

This is files of Random class implementation in txtUml

Copy link
Copy Markdown
Member

@budaimartin budaimartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you have misunderstood the task a little. You have to write a wrapper class for the original Java class. So you need an instance of the Java object and simply call the same methods on it. For example:

public class RandomImplementation implements Random {
   java.util.Random instance = new java.util.Random();
   // ...
  @Override
  public int nextInt() {
     return instance.nextInt();
  }
  // ...
}

txtUML supports double so you can add nextDouble(), nextGaussian() and next(int bits).

You use Javadoc comments the wrong way. Java doc comments start wit /** and they are before the corresponding function. For example:

/**
 * This is the Javadoc for function foo. You can see it
 * when you hover the cursor on the function's name
 * in several IDE's and is very informative.
 * 
 * @param bar description of the parameter bar
 * @return description of the return value
 * @throws some exception may be thrown
 */
  public int foo(int bar);

See my other comments below.

@@ -0,0 +1,76 @@
package hu.elte.txtuml.stdlib.math;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package name is wrong. The Java Random class is in the java.util package.

* The algorithms implemented by class Random use a protected utility method that on each invocation can supply
* up to 32 pseudorandomly generated bits.
*/
public interface RandomInterface extends ExternalClass {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the interface should be Random.

* The general contract of nextInt is that one int value is pseudorandomly generated and returned. All 232
* possible int values are produced with (approximately) equal probability.
*/
public int nextLong();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type long is currently not supported by txtUML. This function can be omitted.

@@ -0,0 +1,44 @@
package hu.elte.txtuml.stdlib.math;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the package name here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants