Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Jenny Daniels

Greenhorn
+ Follow
since Oct 23, 2012
Jenny likes ...
Eclipse IDE Opera Java
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
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jenny Daniels

Half of the diamond done but I'm having some trouble visualizing the code for the second half. I know it should be an easy modification of the variables but my mind is working a bit slowly today...

Thanks for all the help for far, y'all.

>
9 years ago

Jeff Verdegan wrote:

So, 2 stars, then 6, then 10, and so on?

Time for some basic algebra. What's the equation for a line with the following points?



y = 4x +2 Good look! Okay, so I believe I have know how to tackle the stars.
9 years ago

Jeff Verdegan wrote:Your first step is to write down in English, in very precise, simple steps, exactly how to do this "manually", without any regard to Java or any other programming language.

You might start with literal steps like, "Draw one star on the first line. Draw two stars on the second line," and so on. Then you might refine those steps as you discover the relationships between what goes where and which line you're on, for example, "Draw N stars on the Nth line." Once you've got that worked out, and you can follow the steps exactly as written with pencil and paper and get the result you want, then you're ready for the easy part--translating it to Java.

I would suggest two additional things:

1) Start with something simpler, like just a diamond of stars, without the border or box in the middle. If that proves troublesome, go simpler still, like a triangle of starts--1 on line 1, 2 on line 2, etc.--and then reverse that triangle so that the first line has a bunch of spaces and then the single star on the left, and so on.

2) For each pattern that you do, start with a small number of rows, like 4 or 5. That will make it easier to work through by hand.

I know that may sound like a lot of extra work, but I promise you, it will pay off. If you just jump in head first and try to do it all at once by sitting down and typing public static void main(String[] args), you'll just be setting yourself up for frustration and spinning your wheel.s



Thank you for this. I am able to create a diamond of pure stars that's j wide, represented here:


I am still trying to work out printing two stars on the first line, then increasing by 4 stars with each line like the included image.

Kemal Sokolovic wrote: OP has just earned a title of time waster (at my side). Even the old thread started by OP has been crossposted to other site, and that's not the way to say thanks to those who are trying to help.



This is true! Sorry, I am used to receiving no help at all so I thought one repost was not too bad. However I do understand how that may frustrate those who could help so I really do apologize. I will delete the other thread as soon as I return to a wifi connection where I am not banned (I guess you reported me?) I will be forthright in the future; I am sorry.
9 years ago
Hey hey friendly javaranch,

I'm trying to teach myself java this fall/winter and am completely stuck with this nested loop problem. While this code below excutes the rectangle of astericks in the middle that I want, I have no clue where to begin in terms of crafting the rest of this shape. I reread the chapters in my text on decisions and iteration, but I still am dead stuck. Any suggestions would be greatly appreaciated. Pic related; it's what I want to print in the end.



9 years ago
Hi! I'm having some difficulty with a practice problem that involves creating a Bank and BankAccount class to be tested later against a tester class. The tester has reference to a single Bank object which 'owns' many BankAccount objects.

Here is my code for the Bank and BankAccount classes.

I am pretty sure my BanAccount code is correct but I am not sure the bank is doing what it's supposed to... any help would be much appreciated. I know Bank is supposed to be set up in a way that the instance methods for the bank class are described as so:

addAccount (int acctNum, double initialDeposit) : void -calls constructor

deposit (int acctNum, double amount): void -calls deposit(..)

withdraw (int acctNum, double amount): void -calls withdraw(..)

getBalance(int acctNum): double -calls getBalance()

suspend/open/closeAccount (int acctNum): void -calls suspend()/open()/close() to change account status

getAccountStatus(int acctNum): String -returns the account's status by calling getStatus()

accountTransactionsString(int acctNum): String -calls transactionsString()

summarizeAllAccounts(): String -returns a summary of the bank's accounts (similar to what I've been trying to describe)
9 years ago