Hi, I have the program, which is a traffic simulation, and I have a few linked lists in it. I'd like to ask you what is the easiest way to check if I don't have duplicats in them? The code which runs it looks like that: public static void main(String[] args) { Simulation s = new Simulation(); s.addRoad(Road.Orientation.HORIZONTAL, 50, 5,3); s.addRoad(Road.Orientation.HORIZONTAL, 500,1,4); s.addRoad(Road.Orientation.VERTICAL, 100,3,2); s.addRoad(Road.Orientation.VERTICAL, 600,2,3); s.addRoad(Direction.DOWN, 1,300, 2,3); s.addRoad(Direction.RIGHT, 3 ,340,1,2); s.addRoad(Direction.UP,0,500,2,1); s.addRoad(Direction.LEFT,2, 400,1,2); s.addIntersection(0,2); s.addIntersection(3,0); s.addIntersection(2,1); s.addIntersection(1,3); s.start(); } Simulation extenst Thread, so first I build road system, then add intersection (if there is a T shape intersection …

Member Avatar
+0 forum 0

Why much time is needed to access an applet having swing components the first time?

Member Avatar
Member Avatar
+0 forum 2

The facts: We are talking about a small company (5 persons) with many clients that making real money (we don't) . We provide our own software that has unique features against the e-commerce completion. The problem: the first glimpse of the problem arose around 2012 and made clear around 2014 with web sockets. Some clients didn't want a simple chat with their client but instead a full live eShop where they could negotiate the prices of a product or even start a discussion with a visitor. The solution would be implementing web sockets in to our framework and that worked …

Member Avatar
Member Avatar
+1 forum 7

# Lab Question# We must create a program that do the following: Allow the user to type in a student name the coorosponds with the student's exam score. The program will be able to accpet exam scores till the user types in the phrase "allDone". The code will determine which student has the highest score and give the name and the score to the user. Here is an example of what will be shown in the console.... *Sample Input* Bob 82 Mary 90 James 87 alldone *Sample Output* Mary has the highest score. Her score is: 90. ## Question ## …

Member Avatar
Member Avatar
+0 forum 6

When posting code, I get error > begin a line with 4 spaces in a row (or one tab), preceded by a blank line. 4+ spaces or tabs may not be used anywhere else.

Member Avatar
Member Avatar
+0 forum 5

# Lab Assignment # We must create a program that will print a sorted list of all the students and the corresponding scores listing the highest score first and the lowest score last. In this case I would need a Bubble Sort. ## Question ## This is my "Bubble Sort" method shown in the code block below. public static void bubbleSort(String [] name, double [] score) { double temp; int counter; int index = 0; for(counter = 0; counter < score.length - 1 - counter; index++) { if(score[index] > score[index + 1]) { temp = score[index]; score[index] = score[index + …

Member Avatar
Member Avatar
+0 forum 5

I am in a Computer Science Class and need help with the following Lab Assingment (WARNIG: this entry may be unintentionally long): # Lab Question # We must create a program that will do these three things: (1) Allow the user to type in a student name the coorosponds with the student's exam score. The program will be able to accpet exam scores till the user types in the phrase "allDone". (2) The code will determine which student has the highest score and give the name and the score to the user. (3) Lastly, the code must print a sorted …

Member Avatar
Member Avatar
+0 forum 2

Hi, something weird happened with my program, I mean when I run it I see only grey frame (like I had only JFrame object in my app), then I minimalize application, maximalize it and only then I see all components painted (JButton, rectangels and lines inside Jpanel,...). Changing of frame size helped too, but now I have fixed size, so this is not anoption. Can you tell me what can cause that behaviour. This is class which draw everything: public class Simulation{ JFrame frame; JPanel background; RoadSystem roads; Stats stats; Settings settings; JButton startButton; public Simulation() { frame = new …

Member Avatar
Member Avatar
-1 forum 2

Hi. I'm trying to create a Traffic simulator and I'm stuck on how to get a Car object to turn into a road. I've managed to have a car go straight (which is really easy anyway lol) but I can't really find a way to get it to turn into a road, specifically a left turn. The code I have currently is this: [CODE]import java.applet.*; import java.awt.*; import java.awt.geom.AffineTransform; public class Traffic3 extends Applet implements Runnable { //thread variables Thread t; int i; //double buffer variables Image offscreenImage; Graphics offscr; int width; int height; //car //coordinates for lanes //south road, …

Member Avatar
Member Avatar
+0 forum 9

Hi, I have two problems with application I write in Java. Now it looks like that: import java.awt.*; import javax.swing.*; public class Main{ public Main() { JFrame frame = new JFrame(); frame.setSize(1200,900); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); JPanel background = new JPanel(new GridBagLayout()); background.setBackground(Color.lightGray); LeftPanel lp = new LeftPanel(); background.add(lp, new GridBagConstraints(0,0,1,3,3.0,1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0)); Stats stats = new Stats(); background.add(stats, new GridBagConstraints(1,0,1,1,1.0,1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); Settings settings = new Settings(); background.add(settings , new GridBagConstraints(1,1,1,1,1.0,1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0, 0)); JButton button = new JButton(); background.add(button, new …

Member Avatar
Member Avatar
+0 forum 3

Hi, I'd like to ask you a few questions about a things which don't work right now in my (very simple) graphic interface. The code I have: import java.awt.*; import javax.swing.*; public class Simulation{ public Simulation() { JFrame frame = new JFrame(); frame.setSize(1200,900); frame.setTitle("Traffic simulator"); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); JPanel background = new JPanel(new GridBagLayout()); background.setBackground(Color.lightGray); RoadSystem roads = new RoadSystem(); background.add(roads, new GridBagConstraints(0,0,1,3,3.0,1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0)); Stats stats = new Stats(); background.add(stats, new GridBagConstraints(1,0,1,1,1.0,1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 10, 10, 10), 0, 0)); Settings settings = new Settings(); background.add(settings , new GridBagConstraints(1,1,1,1,1.0,1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, …

Member Avatar
Member Avatar
+0 forum 1

Hi i am new to java and just learning as i go , I the basic of calling mothod arguments and so forth but i am having difficulties calling my array method so it would come up to the terminal to the user when the code is running . i have declared the array list paramter to ( int [] name ) , then called the array MyObject.MyMethod ( 01234 ) . I tried to return the array list then call the method that way but is not worrking please can some one show me the correct way to implement …

Member Avatar
Member Avatar
+0 forum 11

If Anyone Knows , can you please help me how to import the text file to JTable by using JFilechooser ? Even the text file contains the specific charecters line length eg: idUsernamePasswordEmailAgeGender ( ID = 2 Chars, Username = 10 chars ( if username not having 10 chars means, it include space for that, password = 5 chars, email = 5 chars, Age = 2 chars, Gender = 1 chars) Here is my code : i am not getting error . Here i attached my code link. https://coderanch.com/t/704099/java/read-text-file-JTable-JFilechooser#3302082 And my text file values : ( i saved in sampleinput.txt) …

Member Avatar
Member Avatar
-1 forum 3

what is the number of static init that I can have?

Member Avatar
Member Avatar
+0 forum 10

Hi, I need your help with my project. I'm doing traffic simulator, but I don't want it to be static map with moving cars, I want it to have methods to generate the roads with intersection (for now I have few simplifications like the roads are straight vertical or horizontal lanes, for now there is also no roundabouts and priority on road - on each intersection are the traffic lights). I started to code it, but quickly I noticed, that easier way will be first do the graphic (I need just an easy one) and then deal with things like …

Member Avatar
Member Avatar
+1 forum 4

I study the Quicksort algorithm like this : // Java program for implementation of QuickSort class QuickSort { /* This function takes last element as pivot, places the pivot element at its correct position in sorted array, and places all smaller (smaller than pivot) to left of pivot and all greater elements to right of pivot */ int partition(int arr[], int low, int high) { int pivot = arr[high]; int i = (low-1); // index of smaller element for (int j=low; j<high; j++) { // If current element is smaller than or // equal to pivot if (arr[j] <= pivot) …

Member Avatar
Member Avatar
+0 forum 1

Why the part will not have add() and remove() ways whereas Jcomponent Have add() And Remove() ways?

Member Avatar
Member Avatar
+0 forum 2

I am on the latest version of Windows 10, running with SWI-Prolog 7.6.4, and trying to get JPL (Java <->Prolog) running for a school project. I've not had to deal with path issues much but I have done my best to understand the problem. I've added the necessary import statements to my java class file, and the necessary environment variables to my system as per the page here: https://jpl7.org/DeploymentWindows However it *still* does not show up as a valid java package. I've just realized as I write this that maybe I need to reboot. I will try that after posting …

Member Avatar
Member Avatar
+1 forum 3

I do the class but there are some codes I need to help me please : -Write a number of member functions that do the following: •Calculate the student GPA •Search for the highest mark taken in a particular course •Print the ID, first name, and last name of all the students who have already taken a particular course •Print the course code, course title, course mark, course grade of all courses taken by a particular student -Write a main program that does the following: •Define an array of objects of each one of the above three classes •Assign data …

Member Avatar
Member Avatar
+0 forum 2

I need to create a class that represents one crayon of a particular color and height(length). Then, I need to design an applet that lets me draw a box of different colored crayons. This is what I have so far: **CLASS:** import java.awt.*; public class Crayon { private final int BOTTOM = 150; private final int WIDTH = 25; private Color color; private int length, location; //---------------------------------------------------------------------------------------------- // Crayon's characteristics. //---------------------------------------------------------------------------------------------- public Crayon (Color color, int length, int position) { color = color; length = length; location = position; } //---------------------------------------------------------------------------------------------- // Draws crayon. //---------------------------------------------------------------------------------------------- public void draw (Graphics page) …

Member Avatar
Member Avatar
+0 forum 5

java language (ArrayList) The Registrar Office at the university has asked you to help them write a Student Information System (SIS). The system can be used to store information about students, courses, and students' transcripts (courses already taken by a student). · Define a class called StudentType that holds information about a student (student ID, first name, last name, major). · Implement each member function (set, get, print, constructor, etc) in the class. · Define a class called CourseType that holds information about a course (course code, course title, number of credits). · Implement each member function (set, get, print, …

Member Avatar
Member Avatar
+0 forum 3

Is there any method in java to generate random number (integer, byte or float) ? Please tell me if any i need it in my program. If possible please give full example. Thanks!

Member Avatar
Member Avatar
+0 forum 1

I am using Netbean IDE 8.1 to build the website. I build a very simple website with simple Javascript function, window.alert(). Upon my testing, I put the button triggered function in the javascript but the function is not triggering. If I put the function under the HTML, it does triggered the function. Any idea? Please note that I also have linked my HTML file to the Javascript file.

Member Avatar
Member Avatar
+1 forum 3

my project is sort score of Student using Linked List and sort algorithm can i coding loop for input from user and save value to node in linked list and export or sort value like this ? Thanks for help or discuss or give any idea (any code is idea from this blog) warning before post prob from this web (Curly braces { } may only be used when posting code.) package javaapplication19; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static javaapplication19.LinkedList.addNode; import static javaapplication19.LinkedList.printLinkedList; public class JavaApplication19 public static void main(String [] args) throws IOException { BufferedReader input = …

Member Avatar
+0 forum 0

Hi I would like to ask you the way i can call a static method when i need to know for exemple what price is bigger. I have 3 prices. How to set it? Help me please

Member Avatar
Member Avatar
+0 forum 1

Hi, I'm using NetBeans with Java. I have create a JFrame with some checkboxes and a button to open browser go to the specific URL based on the checkboxes' values. But how do I auto-login/auto fill the username and password textbox then trigger the login button? Please kindly advise. Thanks.

Member Avatar
Member Avatar
+0 forum 7

Hello everyone. I have been trying to get desired output since last 4 days and so far very near to it. I am really stucked in the logic. Please help me or help me in writing proper logic. Open the attached zip file for whole eclipse project. No need to touch any file except **com.designimplementation.elevator.controllers.ElevatorController** So far I am able to get **Average cycles per customer trip: 42.35841100754549** But I must be **Average cycles per customer trip: 30** Please help me asap. Thank in advance.

Member Avatar
Member Avatar
-4 forum 1

Write a program to read 50 students’ marks, calculate and print the number of students who succeed and the number of students who failed (any marks below 40 should be considered failed).

Member Avatar
Member Avatar
+0 forum 4

The entire point of this dice game is for a user to first roll four dice, if the answer to this roll is a 9,11,18 or 24 the user wins. If they roll a 6, 12, 13, 17, 19 or 23 the user loses. But if the user rolls any other number, that number becomes the goal number and they must roll it again to win, otherwise they roll a 13 and lose. I have most of this code established and functioning - the goal number is a little sketchy but more importatnly there is one more part of the …

Member Avatar
Member Avatar
+1 forum 1

Hi I need to show an image thumbnail in one of jTable cells But I don't know how to do it! I'm using netbeans to design GUI . How can I do that? Thanks

Member Avatar
Member Avatar
+0 forum 11

The End.