32,199 Topics
| |
In main method which should I use? CarOwner owner = new CarOwner("Danni", "123456789"); or CarOwner owner = new CarOwner(); owner.setName("Danni"); owner.setPhoneNumber("123456789"); I know how to make both work, I can edit the class file to suit whichever way it is written in the main method. But what do people do … | |
program for moving a car or object using button(start and stop) in applet and thread function | |
| Hey everyone, I am having trouble on this one practice problem. It is a question that requires another question I already completed to solve this one. The qusetion is "Implement a method allPerfect() that takes an integer parameter end. The method prints every perfect number from 1 to end. Use … |
I wanted to verify is this a good example of a flyweight design pattern: package com.flyweight; public interface Chemical { String getName(); String getSymbol(); Double getAtomicWeight(); } package com.flyweight; import java.util.HashMap; import java.util.Map; public class ChemicalFactory { private static Map chemicals = new HashMap(); private static ChemicalFactory factory = new … | |
public class Jacobi{ // jacobi(a,n) public static void main(String[] args) { int n = 234567,a = 97770; if(n<=0 || (n %2) == 0) return (0); int temp, j=1; if(a<0) { a = -a; if((n % 4) == 3) j = -j; } do while (a!=0) { do while(( a % … | |
I am tryn a currency converter using hash table. What is the technique to use to enble covert both ways. Ex: Dollers to Euro and Euro to Dollers . I can understand how to do it one way using currency as the hashKey and rate as Hashvalue. (I hope that … | |
Hello, Could you please assist me i want to deploy this application as an executable file with the MYSQL database embedded. I have clean and build the application, the jar file is there but nothing happens. The database is stored on local host. Thank you | |
i recent been using my variables names like this boolean is_dead = false; turn out its not right. right conventions is boolean isDead = false; for some reason i dont like the 2nd one. may be bc i been using 1st one for so long. i was wondering is there … | |
Hey, I need some assistance with an assignment that deals with Jframes. The assignment says "For questions 27 to 31, consider the following class: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class A extends JFrame ( private Container c; private JButton b; private JTextField tf; ) Now for the questions: … | |
Hello guys. I am getting this error when I run this file. Can any of you clarify what is wrong in the code? public class csector_node { public double [] relations; public csector_node() { relations = new double [8]; for (int i = 0;i < 8;i++) { relations[i] = new … | |
i wrote a code to implement some basics of priority queue , but apparantly its not giving desired output. the code is implemented using binary heap as its data structure. i tried tinkering here and there , nut no luck... i want to display a given number of max or … | |
Hi to all, I'm making one application for video control in firm...what's the best way to make application which have to access to webcam? There should be option for watching videos from more cams in real time...I read something on google and I found that Swing framework has some options … | |
les say i have a map: //my map is biiger but this is just a ex. int map[][] = {{1, 1, 1 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}}; int camera_pos_x = 0; int camera_pos_y = 0; int camera_speed = … | |
Hi! I recently started teaching Java to myself yesterday via TheNewBoston on youtube. I began working on a few programs from the programmingbydoing website but I'm stuck on this problem:http://programmingbydoing.com/a/gender-game.html It's a problem focusing on nested if statements. Here's my code!: import java.util.Scanner ; public class MainClass { public static … | |
As part of my Uni course i have been given code to edit to create a MineFinder (mine sweeper) game. I have 3 seperate classes to create this game. But for now, my problem lies with this "MineFinderModel class... the tasks i am struggling to complete is as follows: > … | |
Hello, I have build my application and now that I am trying to run the jar file by double clicking on it nothing happens. I tried to access it from my terminal(mac OS) using this line: java -jar "C:\Users\Me\NetBeansProjects\BS1\dist\BS1.jar" But get the following error: Unable to access jarfile Can anyone … | |
hi friends im in need of the basic code for reading a video file as matrices in a frame by frame manner in java. can anyone please help me ? | |
so i got finally done with make my player move right and left, and 1st level. now i want to make my player shoot bullets. i kind of now logic behind it but i need some help. and please let me know if you have a better method of bullet … | |
Hello i m the student of B.E ( Computer Systems ) .. i have to submit my Final year project proposal within 1 month.. my teachers had concerned me to work on android.. but being an engineer student they want a hardware based project from my side.. i have to … | |
I need a little help on writing the following program: Use the Account class to simulate an ATM machine.Create ten accounts in an array with id 0, 1,. . . 9, and initial balance $100. The system prompts the user to enter an id. If the id is entered incorrectly, … | |
I am using Netbeans 7.1 I have 2 jFrame JFrame1 and JFrame2 I just not able to close or hide the JFrame1 when I switch to JFrame2 This is the JFrame1 Code - private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { try{ int flag=0; String sql="Select * from login;"; smt1=con.createStatement(); rs=smt1.executeQuery(sql); String log=jTextField1.getText(); … | |
i trying to my background move left if user hit right key. and background right if user hit left key. that way it will look like my player is moving. the problem is that when ever i hold right key, the background waits 1 sec than moves to left. i … | |
Hello. I have a project for queues simulation to do and I have to follow the MVC pattern. My classes until now are: Client, Queue which represent the Model, Controller, GUI which is the View, and the Main class. If I have those 2 classes representing the Model, how should … | |
How would you implement "clickable" game elements, like they are buttons. But of course, they can move still. | |
Hi, i want to convert a .jsp file to .java file. I read various forums and they said to use tomcat to convert .jsp to .java.I have ran tomcat but it is not doing anything(i cannot write anything). Through command prompt i ran it and it just opens a new … | |
write a program that will create a phonebook,wherein you can add **entries in the phonebook,delete** entries,View all entries and Search **entries.In viewing all entries, the user should have a choice,whether to view the entries in **alphabetical order or in increasing ** order of the telephone number.In searching for entries, the … | |
error: The method paint(Graphics, main) in the type player is not applicable for the arguments (Graphics, main.Display) on line: player_class.paint(g) main.java public class main extends JApplet { Timer timer; Display display_class; Player player_class; /*** init method ***/ public void init() { setSize(800, 400); display_class = new Display(); setContentPane(display_class); }/*** end … | |
Can any one help me writing code which can only creat three digit random number not two digit or one digit number? Following code creates 3 digti but also creats two and one digit number.. public class random { public static void main (String [] args) { double n = … | |
my password program can hide keyboard input . its invisible when i type password. But my qus is how can show password input as asterisk (*) can any one help me please? :p my code is here: public void login() { Scanner input = new Scanner(System.in);//create Scanner object System.out.println("\n"); Console … | |
What I am trying to do is make a program that reads a txt file and converts the number into a double array. import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class rocket { public static void main(String[] args) throws IOException, FileNotFoundException { System.out.println(readLines("/Users/Jeremy/Documents/workspace/altitude.txt")); } public static Double[] readLines(String … |
The End.