Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Method Confusion

$
0
0
Hello, I am having trouble understanding what I am supposed to add in a method I have named addCoin(). I have 3 classes, Coin, Purse, and PurseTester. For the method addCoin() in the purse class the instructions tell me to create "a method called addCoin() that accepts a coin object as a parameter and adds it to the purse. If there is no room in the purse, the method should return false. Otherwise it should return true." Now I already have the if statement for if there's room, but I'm confused as to how I make it accept a coin object as a parameter and add it to the purse. This is my method so far.....
public boolean addCoin() {

		if(totalCoins < numCoins.length) {
			totalCoins++;
			return true;
		} else {
			return false; 
		}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>