Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

David Martínez

+ Follow
since Oct 04, 2016
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Martínez

Hello there, I've been strugling lately trying to get this to work.

I want that the Chat System could only accept 3 users, if another one user tries to log in, it would be notified that the room is full.

3 years ago

Jeanne Boyarsky wrote:Fun! It sounds like you need an array or ArrayList. It also sounds like you need a Car class.

I'm actually writing a mess of a code

I'm only using one ArrayList name OccupiedSlot, which, when the systems starts, the method reads the csv file (where I save all the cars info). The method returns the slot's number that is currently empty and can be occupied.

Btw, could you suggest me a good book about object modeling? I know I have to have a car class, but I don't, I'm fairly new to coding and I'm trying to get better.


SlotOccupied,Agency,Model,ID,CurrentTime, Leaving Time

3 years ago
Hello there!

I'm making a Parking Lot System, and I need timers to execute the leaveLot method.

First, I generate a car in a empty slot, the slots saves the current time and the leaving time (beetwen 1 and 15 minutes after current time).

Since I'm having max 8 cars, I need to keep track each random leaving time generated.

Once the leaving time is met, the car should disappear.

How could I do this ?


3 years ago
Hello there! I'm trying to write a code to replicate a Parking Lot System.

The Parking Lot has 8 cars slots and 12 motorbike slots

This is the layout with some labels showing the cars

The question is, how can I track simultaneously all the slots that are currently being occupied?
3 years ago
Hello there!

I'm working with text files, In one point I need to modify one line of the text file

I'm using opencsv library to get this easily done, but once the modification is done, there is an empty line remaining at the end.

This is the code I'm using to update just one column of the line

This affects my following operations.
3 years ago

timothy adigun wrote:

The Regex, that will work for you can be coined in several ways:
You could you use:

which is also the same things as this

You take the first group, starting from the start of the string, take from 1 to several of the "integer" which ranges from 0 to 9.
That is the group you wanted and so you can then print it out.

I will also suggest that you take a look at this

Thank you for your help! Will look into that.
3 years ago

Henry Wong wrote:

David Martínez wrote:
How should it be the Regex to work the way I need?

First, with regular expressions, it isn't as simple as the regex string itself. You need to tell us how is the regular expression being applied.

And second, you need to tell us which regular expression you are using -- as regular expressions are available in a multitude of languages and frameworks. At this point, I can clearly say that this question is in the wrong forum, but I can't say where it should be moved to!!


I know this is not the correct forum, but I tought I chose Beggining Java

I got a workaround using this expression \\|.*$", ""

With the previous line of code, it removes everything when it finds a '|' character, then using StringUtils  I can remove the remaining Whitespaces.
3 years ago
Hello there!

I have this line: 12894  | 'Coke 2L'   |   Dept[Drinks]   |   Price (10.0)   |   Stock (64)

And I just need the ID: 12894

I'm using this regex: [^0-9.]*\([^)]*\) *

Using the previous Regex:

Without the 2:

How should it be the Regex to work the way I need?
3 years ago

Sergiu Dobozi wrote:I tried to figure it out and with pen and paper and I can only do this with a for loop.
Let's say if you have the number 10, this program tests if 10-0*3 divides by 5, then assigns 10/5 the number of 5cents you need.
If you have 11 then 11-0*3 does not divide by 5.  It's only when b=2 that it becomes true. so 11-2*3 divides by 5 and then you have the number of 3cents and you can pull out from the loop.

This worked perfectly! Thank you so much!
Thank you too, Sergiu!
3 years ago
Hello there!

I'm trying to implement something like the Change Maker Algorithm used by ATM's.

It is a mathematical problem, it says that I can use 5 cents coin and 3 cents coin to get any number greater than 7, for example; to get 8 cents I would need one 5cents coint and one 3cents coin, to get 10 cents I would need two 5cents coins.

This is what I have right now:

And it actually works with several numbers, but if I write 11, 12 or 13 for example, it fails.


3 years ago
I can't edit my previous post

I forgot this, this is the real main class!

3 years ago
Hello there! This is my first post here, I've been learning java for about 2 months now, and I need your help with some questions!

As the title says, I have this homework where I need to make a user input where the user will write his email, the teacher wants it to be like this:

Is it possible to do it with JOptionPane? Or is it more complex than that ?
3 years ago