Sythe.Org Forums     Register     FAQ     Members List     Calendar     Mark Forums Read    
 
Sythe.Org Forums  
   Runescape Gold

Sythe.org — A Virtual Goods Trading Hub

Make real cash! buying and selling in-game items.

We have a no-scam policy.

You can make thousands playing your favourite games here at Sythe.org.

Just sign up an account and follow the rules!


Take me to

Runescape Markets

Other Game Markets

Support Center

Register an Account

Close
Permutation Project
Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 12-23-2010, 12:13 AM
Forum Addict
BANNED
 
Join Date: Aug 2010
Posts: 407
Send a message via MSN to jo3s
Default Permutation Project

Write a Java project that produces random permutations of the numbers 1 to 10. To generate a random permutation, you need to fill an array with the numbers 1 to 10 so that no two entries of the array have the same contents. You could do this by brute force, by calling Math.random() until it produces a value that is not yet in the array. An alternative would be to create a second array and fill it with the numbers 1 to 10. Pick one of those numbers at random, remove it from the array, and append it to the permutation array.

In developing this project, you should create a class called PermutationGenerator. It should have one instance field, an integer array called permutation. It should have a default constructor that constructs the permutation array with 10 memory addresses (if you did not do this when you declared it as an instance field) and calls a mutator method setPermutation() which will fill the array. This class also needs an accessor method getPermutation().

This project also requires a driver class. This driver should print to the console window 10 permutations of the numbers 1 to 10. The output should look something like this:

4 6 10 7 8 3 9 5 2 1

5 4 7 2 8 10 1 6 9 3

1 4 3 5 8 7 6 2 10 9

3 10 2 8 1 4 5 6 9 7

6 1 9 5 3 10 7 4 8 2

3 1 10 8 5 4 6 2 7 9

7 8 2 6 1 3 10 4 9 5

6 9 5 7 4 2 1 3 10 8

5 6 8 1 2 9 4 10 7 3

7 6 8 2 3 5 9 4 10 1

To produce this output, you will have to construct an object of type PermutationGenerator inside a for loop, use this object to call the accessor method, and print the contents of the returned array. Use the enhanced for loop to print the contents of each array.


To submit your solution for credit, follow the instructions on the assignments page. Be sure to include a picture of your output and your code. If you finish early, feel free to help other students in the lab complete their assignment.


All help appreciated
Reply With Quote
  #2  
Old 12-23-2010, 05:44 PM
Member
 
Join Date: Nov 2005
Location: Newcastle, UK.
Posts: 82
Default Re: Permutation Project

Do you need help with any particular part?
__________________
Vouches:

Quote:
Originally Posted by I Am The RWT View Post
Vouch for pottworth got him a 50. He paid first.
Quote:
Originally Posted by ChiN RuNz View Post
Vooooooouch for pottworth! Went first and paid fast. Legit and a nice guy too.
Quote:
Originally Posted by Twis7ed147 View Post
Vouch for pottworth, glitches his gears of war 2 account to level 100 he went first. Smooth trade and nice guy.
Reply With Quote
  #3  
Old 12-23-2010, 07:27 PM
Forum Addict
BANNED
 
Join Date: Aug 2010
Posts: 407
Send a message via MSN to jo3s
Default Re: Permutation Project

I'm just confused overall
Reply With Quote
  #4  
Old 12-23-2010, 09:18 PM
Member
 
Join Date: Nov 2005
Location: Newcastle, UK.
Posts: 82
Default Re: Permutation Project

Well this is how I'd start it (Providing you are stuck on arrays!)

Make the PermutationGenerator class

Make an instance variable "currentIndex"
Make the array
*private int[] array;*

Constructor
Set the currentIndex to 0
array = new array[10];


setPermutation() method
*{
array[currentIndex] = new array(Math.random(), ....*10 spaces*...., Math.random() );
currentIndex++;
}*


I don't know if this will be any help, you weren't specific enough with what you were stuck on.
__________________
Vouches:

Quote:
Originally Posted by I Am The RWT View Post
Vouch for pottworth got him a 50. He paid first.
Quote:
Originally Posted by ChiN RuNz View Post
Vooooooouch for pottworth! Went first and paid fast. Legit and a nice guy too.
Quote:
Originally Posted by Twis7ed147 View Post
Vouch for pottworth, glitches his gears of war 2 account to level 100 he went first. Smooth trade and nice guy.

Last edited by Pottworth : 12-23-2010 at 09:24 PM.
Reply With Quote
Reply



Cheap RS Gold Store  Runescape Gold

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT +1. The time now is 04:05 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.1