Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!

Steven Villarreal

Ranch Hand
+ Follow
since Oct 18, 2017
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
4
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steven Villarreal

Good words of Advice! I will try to see what each part means first before I alter it to use BigIntegers.
1 week ago
I am currently working on a project for my discrete math class and ran into an issue. I have this if statement that originally looked like this

but I need to change it to only use BigIntegers since that's what we have to use for those variables n, x, and b. I did change those variables to BigIntegers already but I need help writing the if statement.

I got this so far,


but I realize that there is redundent code on line one and that it doesn't work exactly as the top if statement. What is going wrong here? Is there a way to use Bit Wise Operators with BigIntegers?
1 week ago
That makes sense! I think I got it to work after around 3 hours of staring at the problem.
3 weeks ago
I have this project for my CIS class that simulates a car lot. It has multiple screens that display certain JTables depending on which screen is selected. I have most of it done except for the overDue screen. I need help with one method in it. This method that I am stumped on will return a boolean if the current date is 30 or more days than the date in which the car or truck was bought. The problem is that the date for the car or truck is in a Gregorian Calendar Date and I thought maybe if I could convert that to a SimpleTimeFormat then I could use a Substring to pull the dates and convert those into ints. After I would do that I would set that to a Calendar date and compare that with the Current date. However this did not work. Here is the method, any suggestions are welcome.

3 weeks ago
The thing is if I do that I get the java.lang.NumberFormatException error because it will try to parse int a letter which it cannot do.
1 month ago
I have this if-else statement I am trying to shorten up but I can't seem to figure out how to do it. The method asks for a string and I am trying to see if the string is either 3 - 15 and if not then ask the user again to type in a string or in this case a number 3 - 15. If the string is either 3 - 15 then I parse int it into an int value named size declared as an instance variable.

The code is here



I want to shorten up the if statement in the middle but I honestly have no idea how to. I thought maybe if I use a for-loop with i starting at 3 until it is equal to 15 but that wouldn't work because it would increment i no matter what to 15.

Could I maybe use a switch statement?
1 month ago
I have this program that simulates a tic tac toe game and asks the user how big of a board they want. The board can be a 3x3 grid and go up to a 14x14 grid. Then I also ask the user how many X's or O's in a row they want in order to win. It is normally 3 but the connections (in a row) cannot exceed the board size so if I have a 14x14 grid, the connections can be 3 and up to 14 but not more than 14. I figured out how to get the horizontal and vertical winners,



but I just need help with the diagonal winners.
1 month ago
We were originally going to have another for loop inside and replace the 3 in the c loop with SuperTicTacToe.getSize() and then inside the new loop have int j be less than connections. Then every time inside the loop we would have an if statement increment a variable like int i up by one. this worked for the connections but your could press X n number of times anywhere till n was equal to connections.



This was really confusing which is why we scraped that idea. You mentioned that if we have a search method that would be easier? How would you achieve that?
1 month ago
I have this game board that simulates a tic tac toe game. It worked perfectly for a 3x3 square with 3 connections or 3 X's or O's in a row to win the game. Me and my partner for this project are trying to allow the user to enter a board size from 3 - 14 and connections size equal to the board size or less than but not less than 3. We need a way of checking the board for connections of n size. We have this code that checks for a vertical connection of 3 within a 3x3 board.



We have the board size variable as SuperTicTacToe.getSize() and the connections variable as connections. We did have it work for checking the board for n number of times which is the connections but they could have been anywhere all throughout the board.
1 month ago
What I am trying to do is display a tic tac toe board but before it displays it will ask how big the board you want it to be. It's just a basic gui that's all.
2 months ago
Thanks for the feedback! All I am trying to do is popup a window that says "Enter the size of the board." Then if they enter something between 3 - 14 then they are good then a grid pops up with what ever value they typed in. Anything that is either not a number or does not fall into the specified range then another window will pop up telling them to enter a number in between 3 and 14. They can either press cancel to gui or type something in that is between 3 and 14 if they choose not to type a number or anything in that range and press ok, they will be prompted with the same window telling them to enter a number within that specified range.
2 months ago
This method checks if there is not anything besides a number in the showInputDialog called userInput. It works but when I enter a negative number like -1 it does not go to the catch statement. Shouldn't it hit the catch statement because Exception e covers it?

Here's the code.



2 months ago
I see what you mean. So for the diagonals make the first loop like r<1 and the second loop c<1. I tried that and seemed to have got the diagonals to work!
2 months ago
How would you do that? Wouldn't you need to check the rows and then each collumn?
2 months ago
I would do that, but later on in my project I have to state the number of rows and columns I want in my board so I could be n number of rows and n number of columns.
2 months ago