I have two classes LightController & Circle. I am trying to create a method to do the following.
1. Increase the size of the circle by increments of 2 as created in grow()
2. Once it has reached the size specified to then reduce in size in crements of 2 as created in shrink()
I have got the method to increase the size but once it reaches the specified size it then does not shrink.The method is called public void lightCycle(int sizeIncrease) and is in the Light Controller class.Both classes can be seen below.
import ou.*;
import java.util.*;
/**
* Class LightController
* This class uses the Circle class, and the Shapes window
* to simulate a disco light, that grows and shrinks and
* changes colour.
I have two classes LightController & Circle. I am trying to create a method to do the following.
1.Grows the diameter of the circle referenced by the receiver's instance variable light, to the argument size.
2. The diameter is incremented in steps of 2, the xPos and yPos are decremented in steps of 1 until the diameter reaches the value given by size.
3. Between each step there is a random colour change. The message delay(anInt) is used to slow down tthe graphical interface, as required.
How can I write the method to do this? I have been fiddling around for ages and just had no luck.
The method is called public void grow(int size) and is in the Light Controller class.
Both classes can be seen below.
import ou.*; import java.util.*; /** * Class LightController * This class uses the Circle class, and the Shapes window to simulate a disco light, that grows and shrinks and changes colour. * */
public class LightController { /* instance variables */ private Circle light; // simulates a circular disco light in the Shapes window private Random randomNumberGenerator;
I just wanna confirm that when a certain processing throws an exception even when said exception happens inside doFilter, any servlet container will never proceed to the next filter right?
I have a JTable that is being used to display, and edit data from a database. When the user presses the Enter key on the keyboard I want a carriage return to occur in the cell they are typing in. I do not want the cursor to go to the next row which is the default behavior.
I'm new to machine learning approach. I want to find user behavior profile using one class SVM in java. I d't know how to do it. Finally, we need to provide privacy to each user and their data.
Requirement:
1. Collect the behavior profile for each user. 2. Apply one class SVM.
I have two classes (Daughter and Son) that contain some very similar method definitions:
public class Family { public static void main(String[] args) { Daughter d = new Daughter(); Son s = new Son(); d.speak(); s.speak();
[Code] .....
Each of those classes has a "speak" method with two out of three lines being identical. I could move those into a parent class, but I need each of the child classes to continue to exhibit its unique behavior. I'm trying the approach below, which replaces the unique code with a call to a "placeholder" method that must be implemented by each child class:
public class Family { public static void main(String[] args) { Daughter d = new Daughter(); Son s = new Son();
[Code] .....
This works and moves the shared code from two places (the Daughter and Son classes) into one place (the new Mother class, which is now a parent class of Daughter and Son). Something about this feels a bit odd to me, though. It's one thing for a child class to override a parent class's methods to extend or alter their behavior. But, here, I've implemented an abstract method in the parent class to alter what happens when the parent class's method (speak(), in this case) is called, without overriding that parent class method itself.
I am working on an assignment that I can't seem to figure out the final part to. The program takes in course data such as the time the class starts and how long it lasts. The time is in military time (0000 - 2400)
I need the output time to be the time the class started, plus the length of the class, and displayed in military time.
I can't for the life of me figure out how to do this. I have gotten a program that works for this time and minutes, and displays the correct 1020. But when I change the information to say
Start time: 0700 Length = 90 minutes
I get:
Endtime = 90
90 is technically correct, the way the formula is setup, but I need it to display 0900 not 90.
Here is the code that I have. Be easy, I'm still learning, and this is just the file I created to get the formula to work. Also, the verbose in here is just for my own debugging to make sure values should be what I'm expecting them to be.
public class calc { public static void main(String[] args) { double hours, minutes, length; double temp; int time = 2400; hours = time / 100; System.out.println("Hours are: " + hours);
I have two classes. time_runner is used for testing my code.
This is what I'm using to test my code:
class time_runner { public static void main(String str[]) throws IOException { Time time1 = new Time(14, 56); System.out.println("time1: " + time1); System.out.println("convert time1 to standard time: " + time1.convert()); System.out.println("time1: " + time1); System.out.print("increment time1 five times: "); time1.increment();
[code]....
The two constructors are "Time()", which is the default constructor that sets the time to 1200, and "Time(int h, int m)" Which says If h is between 1 and 23 inclusive, set the hour to h. Otherwise, set the hour to 0. If m is between 0 and 59 inclusive, set the minutes to m. Otherwise, set the minutes to 0. Those are my two constructors that I pretty much have down. The three methods however I'm having trouble with. The "String toString()" Returns the time as a String of length 4. The "String convert()" Returns the time as a String converted from military time to standard time. The "void increment()" Advances the time by one minute.
public class Time { private int hour; private int minute; public Time(int h, int m) { if(h > 1 && h < 23) hour = h;
my first assignment is to convert a md5 string to password of the user, the MD5 function is available, i just need to call it and print the result. Here is my code. I can't call the md5 because of the String[] and String is different in main and md5 function,modify the code so it can run properly, also the input has to be entered from command line.
import java.security.*; public class PasswordCracker { public static void main (String[] args){ String password; md5(args) System.out.printf(""+password+"");
I'm trying to create a booklist in java using swings but I'm facing a problem. I don't know how to add a search function to my list. I need a search box with the book names.
where I have to write a Java program that asks for user input regarding a book and provides information based on that input like the number of pages required, number of words on the final page and if the final page is more than half full, etc. We are told that each page should have 250 words maximum to use for our calculations. The problem I am having here is that when the total number of words is a multiple of 250 the output tells me that there are 0 words on the last page when in fact there are 250. I've tried messing around with mod functions in this format ((x+a)%250)+y which is what the professor told us to use instead of creating an if-statement for this case but I haven't been able to crack it. I don't think I fully understand how the mod function cycle could work for this case.
import javax.swing.JOptionPane; public class CorreiaFranciscaA1Q1 { public static void main(String[] args) { String ManuscriptTitle = JOptionPane.showInputDialog ("Please enter a book title."); String AuthorName = JOptionPane.showInputDialog ("Please enter the author name."); String TotalWords = JOptionPane.showInputDialog ("Please enter the number of words.");
[code]....
Above if totalWords is a multiple of 250 like 17500 then wordsFinalPage will give us 0 and I need it to give 250. How can I do that without using an if statement but instead using a mod function?
Using JPA 2.1, I have been trying without luck to call a function that returns a REF CURSOR containing RECORD TYPES. Is there a way of doing this?
One Example of trying:
Query query = em.createNativeQuery("select my_package.my_function from dual"); Object a = query.getSingleResult();
I have also tried to use the StoredProcedureQuery though this does not look like it can return the functions value.
Produced
org.springframework.orm.jpa.JpaSystemException: No Dialect mapping for JDBC type: -10; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: -10 at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:244)
I just wanted to ask that when we invoke a function by passing certain arguments in it ,so for instance I have certain variables like a,b and c with some values assigned to them,so when I invoke a function like func(a*b , 8, c+a) where the function func accepts parameters like func(int x,int y,int z) ,so is there any order of evaluation of expressions defined like the value of c+d would be evaluated first and then assigned to variable z ,because in C we have sequence points and since comma when acting like a separator is not a sequence point so any of the expression can be executed first ,so basically is there any sequence in which the function arguments are assigned to the parameters of the function or any relation with the stack implementation.
Even in C ,the printf starts executing its expressions from right to left so basically in why does it happen there when comma is a separator in a function argument.
import java.awt.*; import java.awt.event.*; import javax.swing.ImageIcon.*; import java.awt.Font.*; import javax.swing.*; //import java swing to use the Jframe etc public class MathQuiz extends JFrame implements ActionListener
[Code] .....
I have 2 JButtons on my JFrame and i would like to add a function to it when i click on them.
I would like the JButton calculator allow me to open another JFrame if thats possible and i would like the JButton Exit allow me to exit the current Frame.
import java.io.BufferedReader; import java.io.InputStreamReader; public class vowels{ public static void main(String arg []) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter a String : ");
Is it possible to create a JInternalFrame class with additional public functions that can be called from the desktop? Here is some snippets of the code. This is the Internal Frame with the public functions added after the constructor.
public class Search_Ifr extends javax.swing.JInternalFrame { /** * Creates new form Search_Ifr */ public Search_Ifr() { initComponents();
[code].....
The line " ifrSearch.setTabPaneIndex("tabCust");" is throwing a compile error that the method is not found.
I am using AXIS2 tomcat6 and jre1.6.0_07 and I created java project using net beans. but when I execute java2wsdl I am getting the following. Can you solve my problem? Also I would like to know what is the function of java2wsdl and its parameters?T