Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old May 4th, 2008, 10:09 AM
geonish geonish is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 1 geonish User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 48 sec
Reputation Power: 0
Homework - ScoresArray (Class has array contained in instance variable)

Hello. I would appreciate it, if someone could look at this program and help me out. I think I have a good start. Maybe everyone can help me out with a specific step? (One person does step 1, the other does step 2, etc).

Directions for code:
http://www.fileden.com/files/2007/4/25/1016937/ScoresArray.doc

Code:
// Nishant Jindal
// May 5th 2008
// ScoreArray (JN49_2)

class ScoreArray
{
	// instance variables									// step 1
	private int[] scores = new int [0];
	int numScores = 0;
	
	// constructor											// step 2
	ScoreArray(int maxScores, int nScores)
	{
		scores = new int [maxScores];
		nScores = 0;
		numScores = nScores;
	}	
	
	// methods
	public String toString()								// step 3
	{
		String msg = "{";
		
		for ( int i = 0; i < scores.length; i++)
    	{
		if (msg.length() > 1)
        msg += ", ";
      	msg += scores[i];
		}
  
    	return msg + "}";
  }
		
	//	msg = "Number of slots in array: " + scores.length;
		
	//	return msg;
		
//	}
	public void addScore(int score)							// step 4
	{
		
	}
	public int lowScore()									// step 5
	{
		int lowestScore = 0;
		
		return lowestScore;
	}
	public int positionSmallest(int startPosition)			// step 6
	{
		int smallestPos = 0;
		
		return smallestPos;
	}
	public void swap (int position1, int position2)			// step 7
	{
		int x = 0;
    
		x = scores[position1];
		scores[position1] = scores[position2];
		scores[position2] = x;
	}
	public void lowToHigh()									// step 8
	{
		
	}
}

class ScoreArrayTest										// step 9
{
	public static void main (String[] args)
	{
		
	}
}

Reply With Quote
  #2  
Old May 4th, 2008, 02:05 PM
scotland87 scotland87 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Location: Scotland
Posts: 329 scotland87 User rank is Second Lieutenant (5000 - 10000 Reputation Level)scotland87 User rank is Second Lieutenant (5000 - 10000 Reputation Level)scotland87 User rank is Second Lieutenant (5000 - 10000 Reputation Level)scotland87 User rank is Second Lieutenant (5000 - 10000 Reputation Level)scotland87 User rank is Second Lieutenant (5000 - 10000 Reputation Level)scotland87 User rank is Second Lieutenant (5000 - 10000 Reputation Level)scotland87 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 9 h 55 m 47 sec
Reputation Power: 64
Whats the problem you are getting?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Homework - ScoresArray (Class has array contained in instance variable)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway