Hi everybody
I'm making a project where i need to make a simulation of a traffic light.
The cars appear randomly, and are represented by letter, the traffic light stays open for x seconds, then it closes. The output is something like this.
0: ....-
1: ....-
2: a...-
3: .a..-
4: ..a.-
5: b..a|
6: .b.a|
7: ..ba|
8: ...ba|
9: ....ba|
10: .....b-
11: ......-
...
42: .j.i..h-
43: ..j.i..-
44: k..j.i.-
45: .k..j.i|
Thanks a lot in advance.
8 4396
Hi everybody
I'm making a project where i need to make a simulation of a traffic light.
The cars appear randomly, and are represented by letter, the traffic light stays open for x seconds, then it closes. The output is something like this.
0: ....-
1: ....-
2: a...-
3: .a..-
4: ..a.-
5: b..a|
6: .b.a|
7: ..ba|
8: ...ba|
9: ....ba|
10: .....b-
11: ......-
...
42: .j.i..h-
43: ..j.i..-
44: k..j.i.-
45: .k..j.i|
Thanks a lot in advance.
We aren't going to do your homework for you. Did you have a question about this or did you just want to share?
I don't want anyone to solve this for me, i just need some help in some parts.
For example this part: - for (d=0; d <= m; d += 1) {
-
System.out.println(d);
By the way, 'd' are the seconds, 'm' the second the program stops, and 'n' the time the traffic light takes to change.
This cicle doens't seem to work, but if i put a number instead of the 'm', it works properly, if 'd' is every second, i want it to stops once it reaches the value of 'm', but i can't get it to do that.
I don't want anyone to solve this for me, i just need some help in some parts.
For example this part: - for (d=0; d <= m; d += 1) {
-
System.out.println(d);
By the way, 'd' are the seconds, 'm' the second the program stops, and 'n' the time the traffic light takes to change.
This cicle doens't seem to work, but if i put a number instead of the 'm', it works properly, if 'd' is every second, i want it to stops once it reaches the value of 'm', but i can't get it to do that.
First, as I'm sure you'll quickly learn, having variable names like "seconds' and "stopSecond" will eliminate the need for you to say things like "By the way, 'd' are the seconds, 'm' the second the program stops..." In case you can't read between the lines, use descriptive variable names. The other problem is that I have no idea how to help you because you have not given me all the information about how your loop works, there is some random variable in there and I don't know what it is.
Have you made sure that 'm' has been initialised? If it is has not then it will either never execute the loop because the program does not know what 'm' is..
Have you made sure that 'm' has been initialised? If it is has not then it will either never execute the loop because the program does not know what 'm' is..
Exactly! Which brings us back around to variable names. Please use descriptive variable names.
Exactly! Which brings us back around to variable names. Please use descriptive variable names.
Story time: I was teaching Java and I saw that one student's Java code had the variable names: variable1, variable2, variable3, ... I pointed this out and he still didn't see the problem. I told him that Java is an object-oriented language, so suggestive names shouldn't be hard to think of. Later I checked his code and he had renamed the variables... to object1, object2, object3...
Kids are very dumb at times.
Anyway, I was having a problem with String706 in my program, it's the one right after String705, and I think it leads into String707...
Story time: I was teaching Java and I saw that one student's Java code had the variable names: variable1, variable2, variable3, ... I pointed this out and he still didn't see the problem. I told him that Java is an object-oriented language, so suggestive names shouldn't be hard to think of. Later I checked his code and he had renamed the variables... to object1, object2, object3...
I don't understand what the problem here is...?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bla |
last post by:
Hi,
There is a new Yahoo group called " Traffic-Cams "
This group discusses everything related to online and realtime
traffic-cameras
We have a very extensive links-section with links to...
|
by: macca |
last post by:
Hi,
I would like to create a control that looks like a set of traffic lights.
This will output alarm states and if the user clicks on the control it will
open up a dialog that gives more...
|
by: Wouter van Teijlingen |
last post by:
Dear Readers,
This is my first post to this group. I was pointed to this group in a
other vb group, so i have better luck here!
For my learning curve of VB .NET i want to make a traffic...
|
by: matt |
last post by:
Does anyone know of a service, that provides driving traffic information in
the form of xml? I see several large cities have information on the web,
including traffic cameras. traffic.com has an...
|
by: jaja99 |
last post by:
hello to all..
PLEASE HELP ME!!
i wanted to make a traffic light in vb using if then else..
3 circles (red, yellow & green) and a timer
i don't know how to make them appear one by one.....
|
by: Brigitte Behrmann |
last post by:
Hi There
This is my first time on the site. I am studing information technology and one of my subjects is HTML & Javascript. I am battling and have an assignment due, please help!
I need to use...
|
by: juvilan |
last post by:
I need a code for my thesis and I don’t know how to create a VB code for the traffic light.
|
by: davidjacob |
last post by:
any program code in vb studio that can help in designing traffic light is appreciated
thanks
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |