Preview

Traffic Lights in java

Satisfactory Essays
Open Document
Open Document
284 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Traffic Lights in java
Traffic Lights in java object oriented programming - Source: http://yoursamplecode.blogspot.com/

import javax.swing.JFrame;

public class TrafficControlApp {

/** * @param args */ public static void main(String[] args) { TrafficLight application = new TrafficLight(); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }

}

import java.awt.Color; import java.awt.Font; import java.awt.Graphics;

public class TrafficFixtureForward{

public int locateX; public String direction; public TrafficFixtureForward(String direction, int locateX){ this.locateX = locateX; this.direction = direction; } public void trafficLight(Graphics g, int state){ g.setColor(Color.black); g.setFont(new Font("Arial",Font.BOLD, 12)); g.drawString(direction, (locateX+4), 250); switch(state){ case 1: g.setColor(Color.red); g.fillOval(locateX,30,50,50); g.setColor(Color.black); g.fillOval(locateX,90,50,50); g.setColor(Color.black); g.fillOval(locateX,150,50,50); break; case 2: g.setColor(Color.black); g.fillOval(locateX,30,50,50);

g.setColor(Color.yellow); g.fillOval(locateX,90,50,50);

g.setColor(Color.black); g.fillOval(locateX,150,50,50); break; case 3: g.setColor(Color.black); g.fillOval(locateX,30,50,50);

g.setColor(Color.black); g.fillOval(locateX,90,50,50);

g.setColor(Color.green); g.fillOval(locateX,150,50,50); break; case 4: g.setColor(Color.black);

You May Also Find These Documents Helpful

  • Satisfactory Essays

    In this dashboard, researcher chooses both qualitative and quantitative data. After all, in that case the balanced scorecard will offer a forward looking in which just quantitative data is not capable of.…

    • 326 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    1) Negative externalities - . Negative externalities are the negative impacts on the third party. The social cost Private cost + External Cost and Social Benefit = Private benefit + External benefit. If externalities do not exist the social and private costs and social and private benefits are the same. Externalities create a divergence between private and social costs of production and private and social benefits of consumption.…

    • 4806 Words
    • 20 Pages
    Powerful Essays
  • Good Essays

    Abstract. Imagine, you are a police officer. You start your shift with a routine vehicle stop with what appears to be a broken tail light. Two hours later you are writing a report that includes; there was no broken tail light, only a taillight that is covered with colored tape. During the stop this car also was in question if it had anything to do with anyrecent previous crimes involving the death of an officer. This was not the case either. However, instead of letting the driver go, as there is no reason to detain her any further, the driver is unconscious in the hospital and upon waking will be arrested for having drugs and a gun in her vehicle that was found after the crash into the telephone pole. Mistakes like this do not have to…

    • 872 Words
    • 4 Pages
    Good Essays
  • Good Essays

    City Road is a busy street in Cardiff. It has a variety of businesses and residents, creating dynamics which change according to the time of day. Many of the businesses are shops, such as Xquisite Africa which caters to the ethnic residents who have felt in the past that their needs were not met. There are also restaurants and takeaways that thrive at night, the majority of customers being local students and young people living in the area. The Making Social Lives DVD shows local resident Lloyd Robson talking to people who have access to City Road and it highlights differences in people's experiences and perceptions. Whilst a street is a relatively small area there are some people who benefit more than others from aspects of the street; it's infrastructure, such as street furniture and facilities, such as restaurants and clubs. There are some people who are actively disadvantaged by these same features and these can become inequalities. I would like to describe how certain people in society experience inequalities in City Road and give examples.…

    • 756 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Premises and at all places on the Premises, and shall not make or permit any loud or improper noises, or otherwise disturb other residents;…

    • 461 Words
    • 2 Pages
    Good Essays
  • Good Essays

    With my observance I have seen many California citizens speed through red lights, make inappropriate lane changes, run through stop signs, make unauthorized lane changes and commit many other traffic violations all while in the presence of active emergency response team's (ERT's). I have not heard of any specific laws set to regulate drivers who violate California traffic laws while in the presence of a responding ERT vehicle. Without these laws being set strictly, police, fire, ambulance and other rescue…

    • 417 Words
    • 2 Pages
    Good Essays
  • Better Essays

    Many motorists argue that with every citation that is given out, points are immediately added to motorists licenses, thus raising their insurance rates. Proponents argue that traffic cameras exist for the safety of drivers and pedestrians; they are responsible for the decrease in collisions and making sure pedestrians are not getting mowed over by reckless drivers. Supporters say the function of the cameras have nothing to do with a drivers insurance rate rising (De Bose). In any case, if traffic cameras affected the motorists insurance rate, red-light and speeding cameras would help lower their insurance rate by reducing the amount of collisions the driver is involved…

    • 2662 Words
    • 11 Pages
    Better Essays
  • Good Essays

    “There were no cars or people in the area and what I did was perfectly safe. What was the point of giving the ticket? It's time to hire educated police officers who can exercise judgment.1", cried Bob Miller to one of the columns of Gary Richards on July 17, 2016. Bob apparently received a ticket on a red light while he was turning right in Campbell, complaining that he should have received a warning ticket instead.…

    • 504 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Have you ever seen a stop sign? Have you noticed the color of said stop sign? I have, and I don’t think that the color of the stop signs should be red. I believe that a brighter or more neon color should be used in replacement of the red color we are of which we are accustomed so that they signs can be seen well. Into the bargain, some people are colorblind and cannot see the red coloring. Without this ability, it would render them incapable of acknowledging the correct sign. Furthermore, the white lettering on the sign may not be visible against the possible glare of the sun. If they could not see the lettering, or even the shape of the sign, they could easily mistake the sign for another. So, though the red stop sign has been used for nearly 50 years, it may be posing a safety hazard and, frankly, is becoming out-of-date.…

    • 734 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Traffic Losses

    • 4831 Words
    • 20 Pages

    However, there is no such thing as a free lunch. We pay for these advantages with our lives, property and the increasing costs in all categories of our existence for the motor vehicle.…

    • 4831 Words
    • 20 Pages
    Powerful Essays
  • Satisfactory Essays

    In this lab we programed a finite state machine in VHDL and then we tested it. After that, we simulate the various tail light operations for a T-Bird automobile.…

    • 415 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    light so they can go. No one, not even the driver knows when this light is going to light…

    • 473 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Traffic congestion is one of the main problems in big cities like London, New York, Copenhagen, and Delhi. The primary causes of it are high population and movement of people. With progress in engineering, humanity invents many initiatives to solve this problem. One of the that is public transport area, particularly Metro. The Metro is an underground railway system of the city. According to Business Traveler (2012) the oldest subway was built in London in 1836 and to date the London Metro is the first in the ten top metros of the world. Ahead 2012, in top ten metros of the world there were included subways of Paris, Madrid, Stockholm, Berlin, and Tokyo after the London Metro respectively. The focus of this essay is an evaluating of the effectiveness of underground railway systems in reducing traffic congestion. In order to properly assess the efficiency of metro it is necessary to find, describe, and analyze the transport impact of the metro on car and bus traffic growth and evaluate city traffic in the near and distant future after building a metro.…

    • 954 Words
    • 4 Pages
    Good Essays
  • Good Essays

    City Road Case Study

    • 852 Words
    • 4 Pages

    Drawing from what you have learnt from the Making Social Lives DVD and Learning Companion 1, outline how material things on City Road favour the activities of some groups of people over others.…

    • 852 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Java Environments

    • 1345 Words
    • 14 Pages

    CSCI 1101 Computer Science II Assignment No. 2 Date Given: January 31, 2011 Due: February 18, 2011 David Mongrain B00554371 Parking ticket simulator ParkedCar.java //Object representation of a car. public class ParkedCar { private String carMake; private String carColor; private int carLicense; //Constructs the car, with given car make, car color, and car license.…

    • 1345 Words
    • 14 Pages
    Satisfactory Essays