Frank Ponce

Greenhorn
+ Follow
since Nov 22, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Frank Ponce

I need some help figuring out what this program does....I understand how the knapsack object with capacity 30 and the array object of size 5 are created. The thing that i cant seem to figure out is the "answer" method, Is that method using recursion?? The output when the program is run is:
Total Value: 38

The data.txt file has the following values:
30
5
20 10
10 7
15 14
18 18
7 15

Ive tried everything i can think of and if i


after



The output is:
20 10 20 15 20 10 20 18 20 10 20 15 20 10 20 27 20 10 20 15 20 10 20 38 20 10 20 35 20 30 20

No idea where this comes from

As well as putting



after




which outputs:

0 0 0 0 0 0 0 0 0 0 0 0 20 20 20 0 0 0 0 0 20 20 0 0 20 0 0 20 30 35 38

and again no idea where dontTake is equated to these values


17 years ago
I am making an arbitrary size multi dimensional array of object Square...the size of the array is decided by the args array casted to an int. The array of squares is for a game of "lines". Hopefully you know that game because i don't want to explain it. The problem i am having is that i cant figure out how to set the top,bottom,left,right sides of the squares when the user enters the place where they want the line placed. I think opnce i can figure this out i can figure out how to reference the output board to output "marked line". Some of the code listed below has some arbitrary code commented out...pretend thats already deleted

Heres the code i have:
(3 classes)

17 years ago
Thanks for the help!11 With that example i just figured it out
17 years ago
Basically i am somewhat at a loss as to how to properly begin and implement this program... i understand the concept behind having three classes (Square, Board, myDriver)...the thing that is keeping me from knwoing how to start this is the creation of "squares". The board class is supposed to create a 2 by 2 array of squares...i cant seem to figure out how to do this since each square needs a side (top,bottom,left,right which is a boolean value). The whole program set up is below:



Write a program (consisting of 3 classes) which allows two
human players to play the game Lines (described in class)
on a 3 by 3 grid (ie with a gameboard consisting of 4 squares).

Your first class will be called Square. This class will have
4 private boolean variables (top/bottom/left/right) with accessors
and mutators. You may add other variables/methods as desired. For
example, you may want to have a method called complete (telling
whether all four sides have been used).

Your second class will be called Board. This class will have
a private variable layout which is a 2x2 array of Squares.
Add methods as necessary. For example, you probably want to
have a method called markLine which takes two ints and
marks the line between those integers (if it exists) and another
method toString which returns a String which represents the
board. You may add other variables/methods as desired. For
example, I used 2 helper methods called markVert and markHoriz.

Your last class will be called Driver. This class will have a
main method (and possibly helper methods) which creates an
instance of Board and takes input from the two players (allowing
each to draw one line). Once all lines have been marked, it should
print out the score.
17 years ago