How to test this code ???
Hi All,
One quick question:
..>>>>How do you test below InterfaceImpl classes in a simple program to test the code ???
//below is the sample of the example I am running .
Thanks
Jack
//interface 1
same package;
interface someInterfaceName1 {
public void setLastName();
public String getLastName();
//inerface 2
same package;
interface someInterfaceName2{
public void setBillingAddress(somename1 billing){
public void setShippingAddress(somename1 shipping){
// implementation class1
samepackage;
public class someInterfaceName1Impl implements someInterfaceName1 {
private String lastName="";
someInterfaceName1Impl();
public void setLastName(String lastName){
this.lastName=lastName;
public String getLastName(){
return LastName;
//implementatio class2 for interface 2
samepackage;
class someInterfaceName2Impl implements someInterfaceName2
public void setBillingAddress(interface1 billto){
billto.setlastName(someValue); --?????
public void setShippingAddress(interface1 shipto) {
shipto.setFirstName(someValue); --- ?????
//How to test the code ??
package samepackage;
class testMyCode {
public static void main(String args[]){
// how do you get the interfaces implementation here to test with dummy values ????
Something along these lines (but departing from your code a bit...) public static void test() {
Interface1 ifc1 = new Impl1();
String tmpStr;
int tmpInt;
ifc1.setName("joe");
tmpStr = ifc1.getName();
if (!("joe".equals(tmpStr))) {
System.err.println("set/getName failed. Put in joe but got out " + tmpStr);
ifc1.setBirthdate("May 1 1980");
tmpInt = ifc1.getAge();
if (tmpInt != 24) {
System.err.println("setBirthdate/getAge failed. Put in May 1 1980, expected 24 but got " + tmpInt);
try {
tmpStr = "Booger 99, 19seventy-beer";
ifc1.setBirthdate(tmpStr);
//shouldn't get here
System.err.println("setBirthdate accepted invalid date: " + tmpStr);
catch (InvalidBirthdateException exc) {
// we want this, since it means our code properly rejected a bad date
} Or, when you start writing serious code, look into junit
ジ
Similar Messages
-
Anyone knows how to make this code to netbeans??
anyone knows how to make this code to netbeans?? i just want to convert it into netbeans... im not really advance with this software... anyway..just reply if you have any idea...or steps how to build it... etc.... thanks guys...
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.util.regex.*;
public class FilterTable {
public static void main(String args[]) {
Runnable runner = new Runnable() {
public void run() {
JFrame frame = new JFrame("Sorting JTable");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Object rows[][] = {
{"AMZN", "Amazon", 41.28},
{"EBAY", "eBay", 41.57},
{"GOOG", "Google", 388.33},
{"MSFT", "Microsoft", 26.56},
{"NOK", "Nokia Corp", 17.13},
{"ORCL", "Oracle Corp.", 12.52},
{"SUNW", "Sun Microsystems", 3.86},
{"TWX", "Time Warner", 17.66},
{"VOD", "Vodafone Group", 26.02},
{"YHOO", "Yahoo!", 37.69}
Object columns[] = {"Symbol", "Name", "Price"};
TableModel model =
new DefaultTableModel(rows, columns) {
public Class getColumnClass(int column) {
Class returnValue;
if ((column >= 0) && (column < getColumnCount())) {
returnValue = getValueAt(0, column).getClass();
} else {
returnValue = Object.class;
return returnValue;
JTable table = new JTable(model);
final TableRowSorter<TableModel> sorter =
new TableRowSorter<TableModel>(model);
table.setRowSorter(sorter);
JScrollPane pane = new JScrollPane(table);
frame.add(pane, BorderLayout.CENTER);
JPanel panel = new JPanel(new BorderLayout());
JLabel label = new JLabel("Filter");
panel.add(label, BorderLayout.WEST);
final JTextField filterText =
new JTextField("SUN");
panel.add(filterText, BorderLayout.CENTER);
frame.add(panel, BorderLayout.NORTH);
JButton button = new JButton("Filter");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = filterText.getText();
if (text.length() == 0) {
sorter.setRowFilter(null);
} else {
try {
sorter.setRowFilter(
RowFilter.regexFilter(text));
} catch (PatternSyntaxException pse) {
System.err.println("Bad regex pattern");
frame.add(button, BorderLayout.SOUTH);
frame.setSize(300, 250);
frame.setVisible(true);
EventQueue.invokeLater(runner);
}its okay onmosh.....what we need to
this...forum....is to have a good......relationship
of programmers......and to start with .....we need to
have a good attitude........right.....???.....no
matter how good you are in programming but if you did
not posses the right kind of attitude....everything
is useless.....in the first place....all we
want....is just to ask...some....help....but
conflicts......but unluckily......we did not expect
that there are members in here which......not
good...to follow.....just as suggestion for those
people not having the right kind of attidude...why
can't you do in a very nice message sharing in a very
nice....way....why we need to put some
stupid....stuff...words.....can't you live with out
******* ****....its not.....lastly especially you
have your children right now and people around...that
somehow......idiolize...you even me....is one of
them......but showing but attitude....is not
good......tnx....hope you'll take it this....in the
positive side.....be optimistic...guys....the
world..is not yours....all of us will just past
away....always..remember that one.....treasure..our
stay in this....temporary home.....which...is
world....Whoa. That post seems to be killing my brain.
URK
Join........us..........do not be..........afraid....... -
Preparedstatement - please test this code!!
I hope someone can test this code and tell me if it works. It seems to work on my computers (win98 and win2000, and access 2002 database, compiling etc,and even returns that it updated 1 record. But the database is unchanged. Commit is default to autocommit, what else could be causing this? None of the setxxx commands work. Yet no errors are given. Please test and let me know. Or, send me similar simple code that works on an access 2002 database from win98 or 2000. I am wondering if access 2002 has something to do with this. I am using default ODBC driver that came with the OS.
Thank you,
Jacques
import java.sql.*;
import java.io.*;
public class test {
static Driver d;
static Connection conn;
final static String jdbcDriver="sun.jdbc.odbc.JdbcOdbcDriver";
static String databaseURL = "jdbc:odbc:" + "dbtest";
public static void main(String[] args) {
try {
d = (Driver) Class.forName(jdbcDriver).newInstance();
conn = DriverManager.getConnection(databaseURL);
PreparedStatement stmt = conn.prepareStatement(
"UPDATE employee SET emp_id = ? WHERE Index = ?");
stmt.setString( 1, "John" );
stmt.setInt( 2, 2);
System.out.println("about to update");
int count = stmt.executeUpdate();
System.out.println("number updated=" + count);
catch( Exception e ){
System.out.println("Error:" + e);
Database: Set up access database with table employee at least 2 records, one field called emp_id, register it in odbc as dbtestOk, for anyone else that encounters this, I found the answer! After a week of very frustrating testing, I stuck in a close() to the connection, and the changes were then actually made. I had counted on Java to close them properly upon exit, but I must specify the conn.close() after the executeUpdate before they take effect. Another weird worm of Java IMHO.
-
Hello
can someone please tell me how to modify this code so that I dont have to enter the file path at all? When i give the same file path constants to both the read and write VIs I'm getting an error message.
Attachments:
read and write.vi 11 KBYup use the low level File I/O opening the reference once, and closing it once.
As for the path selection you have an unwired input which is the path to use. Programatically set that and you won't be prompted to select a path. Usually this is done with a path constant to a folder, then using the Build Path, to set the file name in that folder.
Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously. -
How to implement this code in labview?
How do implement this pseudo code in labview? Please keep in mind "a" and "c" in the code below ARE VARIABLES
for i =0 to i=maxvalue
if i <= a
output = output2
else if i > a AND i<=c
output = output2
else if i < c
output = output3
else i = d
output = output4
I understance i can use a case structures and modify the label, but i do not know how to make the label dependent on a variable value.
ThanksTry an array of boudaries and use threshold array. See this old example:
Now just iterate over an array of values using a FOR loop.
LabVIEW Champion . Do more with less code and in less time . -
How to Optimize this code?
Hi All
I have a procedure which runs fine,but since the data in table XYZ,ABC runs into millions it becomes too slow..Can any one guide me in optimising the code.I have already created indexes on these columns.
CREATE OR REPLACE PROCEDURE test AS
CURSOR c1 IS
SELECT
t.cutGrp,
t.cutGrpCode,
t.modelDesc,
t.startdate,
t.enddate,
avg(t.price) price,
avg(t.netprice) netprice,
sum(t.awdQTY) awardqty,
sum(t.planQTY) revplanqty,
FROM
ABC t
GROUP BY
t.cutGrp,
t.cutGrpCode,
t.modelDesc,
t.startdate,
t.enddate;
counter NUMBER := 0;
l_aggregate NUMBER;
BEGIN
FOR rec IN c1
LOOP
counter := counter + 1;
SELECT
sum(t.anotherQTY) INTO l_aggregate
FROM
XYZ t
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.product_model = rec.modelDesc;
UPDATE XYZ t
SET
t.testQTY = l_aggregate,
t.testprice = rec.price,
t.testnetprice = rec.netprice,
t.testawardQTY = rec.awardqty,
t.testplanQTY = rec.revplanqty,
t.fcstartdate = rec.startdate,
t.fcenddate = rec.enddate
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.cutGrp_Code = rec.modelDesc;
END LOOP;
COMMIT WORK;
END test;
SHOW ERRORS;Hi All
This the only query i could come up with...But this gives me error
ORA-30926 unable to get a stable set of rows in the source tables.Also this code does not address
SELECT
sum(t.anotherQTY) INTO l_aggregate
FROM
XYZ t
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.product_model = rec.modelDesc;<b>This is what i came up with </b> so any code help is appreciated
MERGE INTO sgforecastrecord b
USING (
SELECT
cutGrp
cutGrpCode ,
modelDesc,
startdate,
enddate,
avg(price) price,
avg(netprice) netprice,
sum(awdQTY) awardqty,
sum(planQTY) revplanqty
FROM
ABC
GROUP BY
cutGrp,
cutGrp,
modelDesc,
startdate,
enddate
) t
on (
t.cutstomer_Grp = b.cutGrp
AND t.cutGrp_Code = b.cutGrpCode
AND t.product_model = b.modelDesc;
WHEN MATCHED THEN
UPDATE set
b.testprice = t.price,
b.testnetprice = t.netprice,
b.testawardQTY = t.awardqty,
b.testplanQTY = t.revplanqty,
b.fcstartdate = t.startdate,
b.fcenddate = t.enddate
-
How to optimize this code + is design proper
Well I have to implement tree programming here , what i mean by tree
programming is i have data stored in tree format i,e I have parent
object which will have child objects of same type the level of depth can
go any long:
I am able to store objects in tree format and also able to display properly Here
is code but I am facing problems when i have to filter some child nodes based on some conditions:
I have two question is this code fine is there anything wrong with desin Plus how to handle removing child node in tree scenation where child can be in any place.Below is code
package menu;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.chartis.gp.support.util.BrokerSupportUtil;
import com.chartis.gp.support.vo.Links;
import com.chartis.kernel.user.UserVO;
import com.chartis.kernel.utils.Utils;
public class Utility{
/* IN this class NavModel,CModel,CNode are some dummy classes
* which help us read contents form some resources which are stored in dummy format
* as Example of tree format stored data below is the example
* tree
* child1
* child2
* child3
* child3-1
* child:q
* child:r
* child:a
* child3-2
* child4
private static void populateChildLinks(NavModel navModel, Object objectNode, Links parent ){
try{
List<Links> childLinks = new ArrayList<Links>();
Iterator it = navModel.getChildren( objectNode );
while( it.hasNext() ){
NavNode node = (NavNode) it.next();
CNode contentNode = node.getContentNode();
Links links = new Links();
links.setNodeName( contentNode.getNodeName() );
childLinks.add( links );
if( navModel.hasChildren( node ) ){
populateChildLinks( node, links );
parent.setChildren( childLinks );
catch( Exception e ){
private static Links createCategoryLinks(String categoryLinkName){
Links categoryLinks = new Links();
categoryLinks.setNodeName( categoryLinkName );
return categoryLinks;
public static Links setupLinks(String categoryLinkName,String name) {
Links categoryLinks=null;
CModel contentModel = new CModel();
NavModel navModel = new NavModel();
categoryLinks = Utility.createCategoryLinks( categoryLinkName);
Object objectNode = contentModel.getLocator().findByUniqueName(name);
if( objectNode != null ){
if( navModel.hasChildren( objectNode ) ){
populateChildLinks( navModel,objectNode, categoryLinks );
// This is where i am facing issue once i get list of links of childs
// i have to delete how can i find that particular child in the list
// do i have to iterate through all the links and delete or which
// way is better
private static void filterLinks( Links parentNode,
List<Links> childNodeList ){
List<Links> filteredResourceList = new ArrayList<Links>();
if( childNodeList!=null ){
Iterator<Links> childNodeIt = childNodeList.iterator();
while( childNodeIt.hasNext() ){
Links childNode = (Links) childNodeIt.next();
if(childNode.getChildren().size() >0 ){
filterLinks( childNode, childNode.getChildren() );
boolean removeNode = filterContents( childNode);
if(! removeNode ){
filteredResourceList.add( childNode );
Iterator<Links> filteredResourceIt = filteredResourceList.iterator();
while( filteredResourceIt.hasNext() ){
Links childNode = (Links) filteredResourceIt.next();
parentNode.getChildren().remove( childNode );
// Let us consider this as some dummy method which returns true or false based on some conditions
private static boolean filterContents( menu.Links childNode ){
return false;
package menu;
import java.util.List;
public class Links{
private String nodeName;
private List<Links> children;
public List<Links> getChildren(){
return children;
public void setChildren( List<Links> children ){
this.children = children;
public String getNodeName(){
return nodeName;
public void setNodeName( String nodeName ){
this.nodeName = nodeName;
package menu;
public class TreeDisplay{
public static void main( String[] args ){
Links link = Utility.setupLinks( "SomeName", "ResiyrbceBane");
Utility.filterLinks( link, link.getChildren() );
}Is the utility class with so many static class is ok?Vicky wrote:
Thanks TPD
If you could write more on it , it will be great i rarely find ocasations of using interfaces , however i don't think creating a new tree with valid node could be better solution as you have to create a new tree keeping the same hierarchy .The advantage is that all other components do not need to know that they work with a filtered tree.
Certainly you can do it the other way around bye passing the tree and the filter to eg. the <tt>NotePrinter</tt> Object, but than all components working with the tree meight neet to know that ther are Node filters.
I just came up with the Idea to give the nodes themselfes knowlege of the Filter via <tt>setFilter(Filter<Links> myFilter)</tt>. You would call this on the root node and in the <tt>getChildren()</tt> method you would check if the child apllies to the filter and pass that filter to the eliable childs before putting them into a new collection which is returned to the caller. Ofcause you should initialise the <tt>this.filter</tt> property in <tt>Links</tt> with a <tt>ALL_NODES</tt> constant.
Also you should resist the tamptation to make the <tt>this.filter</tt> property in <tt>Links</tt> static. This would save you one line of code in the <tt>getCildren()</tt> method by the cost that you cannot have different trees with different filters in the same JVM.
This kind of interference between threads is pretty hard to find later in production environments...
bye
TPD -
How to write this code ?
I need to write 3 classes that each one can get to the other with the same instance of the class , so how do i write this code ?
thanks a lottry out singleton pattern with all the three classes. following link may help...
http://www.javareference.com/jrexamples/viewexample.jsp?id=25 -
How to transport this code to an applet
Hi friends..
the following page has a program to capture images from a web-cam.. can u help me how to transport that code into an applet. So that i can import that applet into an html page, where the live video can be streamed.
the link is :- http://forum.java.sun.com/thread.jspa?threadID=247253&start=0&tstart=0
i tried this code. but on html page the code is not being initialized, though the program is getting compiled correctly.
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import javax.media.*;
import javax.media.format.*;
import javax.media.util.*;
import javax.media.control.*;
import javax.media.protocol.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.applet.*;
import com.sun.image.codec.jpeg.*;
public class applet extends JApplet{
static final int WIDTH = 320;
static final int HEIGHT = 320;
//public intoApplet d = null;
public static void main(String args[]){
JFrame frame = new JFrame("Code Converter");
applet a = new applet();
a.init();
frame.getContentPane().add(a);
frame.setSize(WIDTH, HEIGHT);
frame.setVisible(true);
public void init() {
System.out.println("Applet initializing");
intoApplet d = new intoApplet();
getContentPane().add(d);
public void start() {
System.out.println("Applet starting");
public void stop() {
System.out.println("Applet stopping");
public void destroy() {
System.out.println("Applet destroyed");
public class intoApplet extends JPanel //implements ActionListener
public Player player = null;
public CaptureDeviceInfo di = null;
public MediaLocator ml = null;
public JButton capture = null;
public Buffer buf = null;
public Image img = null;
public VideoFormat vf = null;
public BufferToImage btoi = null;
//public ImagePanel imgpanel = null;
public intoApplet()
System.out.print("into swing...");
setLayout(new BorderLayout());
setSize(320,320);
String str1 = "vfw:Logitech USB Video Camera:0";
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
di = CaptureDeviceManager.getDevice(str2);
//ml = di.getLocator();
ml = new MediaLocator("vfw://0");
try
player = Manager.createRealizedPlayer(ml);
player.start();
Component comp;
if ((comp = player.getVisualComponent()) != null)
add(comp,BorderLayout.NORTH);
//add(capture,BorderLayout.CENTER);
//add(imgpanel,BorderLayout.SOUTH);
catch (Exception e)
e.printStackTrace();
public void playerclose()
player.close();
player.deallocate();
}Message was edited by:
rahulsahMaybe this topic helps (JUnit into Applet):
http://forum.java.sun.com/thread.jspa?threadID=5130219&messageID=9469005#9469005 -
How to make this code go faster?
Hi,
I have this code and its really slow. My question is how to make it faster since its taking about 10 hours.
Code:
loop at ti_equi.
select matnr sernr lief_nr kunde datum uzeit bwart posnr
appending corresponding fields of table ti_ser01
from z_objk_ser01
where sernr eq ti_equi-sernr
and matnr eq ti_equi-matnr.
endloop.
delete ti_ser01 where not ( kunde in s_kunnr and
bwart = '631' ).
sort ti_ser01 by matnr sernr datum descending uzeit descending.
delete adjacent duplicates from ti_ser01 comparing matnr sernr.
What this code does is fetch all these fields and then just keeps the one that's been modified at last.
I have created an index by sernr and matnr in table objk which makes it just a little bit faster.
Any helpful answer will be appreciated.
Regards,
Roberto
Edited by: Julius Bussche on Jan 27, 2009 4:29 PM
Code tags added. Please use more meaningfull subject titlesHi roberto
please avoid select statment inside loop.
use code
data: index type sy-tabix.
data : ti-ser011 type standard table of zobjk-ser01 with header line.
select matnr sernr lief_nr kunde datum uzeit bwart posnr
from z_objk_ser01 into table ti_ser01.
sort ti_ser01 by sernr matnr.
sort ti_equi by sernr matnr.
index = 1.
loop at ti_equi.
loop at ti_ser01 from index
if ti_ser01-sernr = ti_equi-sernr
and ti_ser01-matnr = ti_equi-matnr.
move-corresponding ti_ser01 to ti_ser011.
append ti_ser011.
index = sy-tabix.
exit.
endif.
endloop.
endloop.
here i have used one more internal table ti_ser011.
you can delete specific record from ti_ser01 internal table on condition. at that time u don't need to create any other internal table like ti-ser011.
in place of loop select statement---endloop.
you can use this code. I think it will help you.
please find if it is udeful. -
Hello,
I am trying to display country, state within each country,
then person in each state...using cfoutput and group.
i am getting this error...How can i fix this code?
The <cfif> tag requires an end tag to nest
within <cfoutput>, which began on line 21, column
26.<p>The CFML compiler was
processing:<ul><li>The body of a cfoutput tag beginning
on line 26, column 34.<li>The body of a cfoutput tag
beginning on line 26, column 34.</ul>Rather then including <cfif county_q.state neq ''> in
your CF code eliminate any records with an empty state in your
query. The sample appears to have a country, state, and name value
for every record.
If this is not possible please post a more code including:
1. Your query
2. A sample of your data with and without an empty state
value -
Please make suggestions on how to improve this code.
Hello Experts,
I am currently modifying a report where a certain code is giving
me run time error. When I debugged the program, the internal table
has 20,000+ records. Now, is there any alternative to this code?
I really need to speed this up. Help would be greatly appreciated and rewarded.
LOOP AT it_cdpos INTO wa_cdpos.
l_matnr = wa_cdpos-objectid+00(18).
l_charg = wa_cdpos-objectid+22(10).
l_zustd = wa_cdpos-value_new+00(01).
READ TABLE it_batch INTO wa_batch
WITH KEY matnr = l_matnr
charg = l_charg.
IF sy-subrc EQ 0.
l_tabix = sy-tabix.
wa_batch-zustd = l_zustd.
MODIFY it_batch FROM wa_batch INDEX l_tabix
TRANSPORTING zustd.
ELSE.
wa_batch-matnr = l_matnr.
wa_batch-charg = l_charg.
wa_batch-zustd = l_zustd.
wa_batch-code = 'A'. "selected within period
APPEND wa_batch TO it_batch.
ENDIF.
ENDLOOP.Check the SQL statement from which u get the result otherwise
the code which u sent is optimized or u can use the binary search option for the Read statement for MATNR
while the rest of the code is optimized....
or u can use
loop at it_cdpos assinging <fs>.
<FS>-cols = value.
<b>note: in this case <FS>-col = value</b>
u wont have to use <b>modify</b> statement for internal table for updating the line contents
since assinging it to field-symbol will dynamically modifies the contents.
<b>this method is faster than the below modify process </b>
endloop. -
Hi,
I am learning JSP. I made this page which takes up user name and roll and prints it.Can you please show me how to do this in a more better way. Such as instate of 3 page can I combine it into two or any thing that you have in mind...
Thank you very much,
M
Form.html (this gets the user data)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<FORM METHOD="POST" ACTION="SaveName.jsp">
Enter Name:
<input type="text" name="name" value="" size="30" />
Enter Roll:
<input type="text" name="roll" size="30"/>
<input type="SUBMIT"/>
</FORM>
</body>
</html>UserData.java
package newpackage;
public class UserData {
String name;
int roll;
public void setName(String value){
name = value;
public void setRoll(int value){
roll = value;
public String getName(){
return name;
public int getRoll(){
return roll;
}SaveName.jsp
<jsp:useBean id="newpackage" class="newpackage.UserData" scope="session"/>
<jsp:setProperty name="newpackage" property="*"/>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SaveName.jsp</title>
</head>
<body>
<A HREF="NextPage.jsp">Click here</A>
</body>
</html>NextPage.jsp
<jsp:useBean id="newpackage"class="newpackage.UserData" scope="session"/>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h2>Hello World!</h2>
Name = <%= newpackage.getName() %>
<br>
Roll = <%= newpackage.getRoll() %>
</body>
</html>Geesh. Throw that tutorial away. Right now.
Start over at one of those tutorials:
Sun Java EE tutorial part II: [http://java.sun.com/javaee/5/docs/tutorial/doc]
Coreservlet.com tutorials: [http://courses.coreservlets.com/Course-Materials/]
I also highly recommend a book of Bates & Sierra: [http://www.amazon.com/Head-First-Servlets-JSP-Certified/dp/0596005407] -
How to create this code in labview
hello...
please helpe me for this Question
i have create this code "c" in " labview "...
ex c :
if portc.f1==1 {
portc.f0=~portc.f0
ex labview :
if push button ==1 {
round led =~ round led
thanks...
Solved!
Go to Solution.pjr1121 wrote:
See attached image.
Why do people insist on using property nodes to get the value. It has the same issues with race conditions as the local variable but is extremely slow (forces a thread swap to the UI thread). Besides, you should be keeping the value of the LED in a shift register.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Toggle LED.png 16 KB -
How stupid is this code?
Hey I am really trying to improve my code writing- see my last post on for and arrays, but I have written this... its a bit embarrassing how stupid it is, but it works good and I understand how it works, can I use it? It is for a drag and drop exercise where there is a buttons that checks answers and then two dynamci text boxes that give responses.
Cheers
sub
ans1.ans1text.text="beans";
ans2.ans1text.text="chicken";
ans3.ans1text.text="rice";
ans4.ans1text.text="rocks";
ans5.ans1text.text="dirt";
ans6.ans1text.text="poo";
ans7.ans1text.text="dog";
var incorrect:Number=0;
var correct:Number=0;
trace(getRect(target1));
var rightanswers:Array = ["ans1","ans2","ans3"];
var useranswers:Array= [];
this.ans1.addEventListener(MouseEvent.MOUSE_DOWN, pickMe1);
this.ans1.addEventListener(MouseEvent.MOUSE_UP,dropMe1);
function pickMe1(event:MouseEvent):void {
event.target.startDrag();
function dropMe1(event:MouseEvent):void {
event.target.stopDrag();
this.ans1.buttonMode = true;
this.ans2.addEventListener(MouseEvent.MOUSE_DOWN, pickMe2);
this.ans2.addEventListener(MouseEvent.MOUSE_UP,dropMe2);
function pickMe2(event:MouseEvent):void {
event.target.startDrag();
function dropMe2(event:MouseEvent):void {
event.target.stopDrag();
this.ans2.buttonMode = true;
this.ans3.addEventListener(MouseEvent.MOUSE_DOWN, pickMe3);
this.ans3.addEventListener(MouseEvent.MOUSE_UP,dropMe3);
function pickMe3(event:MouseEvent):void {
event.target.startDrag();
function dropMe3(event:MouseEvent):void {
event.target.stopDrag();
this.ans3.buttonMode = true;
this.ans4.addEventListener(MouseEvent.MOUSE_DOWN, pickMe4);
this.ans4.addEventListener(MouseEvent.MOUSE_UP,dropMe4);
function pickMe4(event:MouseEvent):void {
event.target.startDrag();
function dropMe4(event:MouseEvent):void {
event.target.stopDrag();
this.ans4.buttonMode = true;
this.ans5.addEventListener(MouseEvent.MOUSE_DOWN, pickMe5);
this.ans5.addEventListener(MouseEvent.MOUSE_UP,dropMe5);
function pickMe5(event:MouseEvent):void {
event.target.startDrag();
function dropMe5(event:MouseEvent):void {
event.target.stopDrag();
this.ans5.buttonMode = true;
this.ans6.addEventListener(MouseEvent.MOUSE_DOWN, pickMe6);
this.ans6.addEventListener(MouseEvent.MOUSE_UP,dropMe6);
function pickMe6(event:MouseEvent):void {
event.target.startDrag();
function dropMe6(event:MouseEvent):void {
event.target.stopDrag();
this.ans6.buttonMode = true;
this.ans7.addEventListener(MouseEvent.MOUSE_DOWN, pickMe7);
this.ans7.addEventListener(MouseEvent.MOUSE_UP,dropMe7);
function pickMe7(event:MouseEvent):void {
event.target.startDrag();
function dropMe7(event:MouseEvent):void {
event.target.stopDrag();
this.ans7.buttonMode = true;
checker.addEventListener(MouseEvent.CLICK, checker1);
function checker1(event:MouseEvent){
trace("Checker");
right.text="";
wrong.text="";
useranswers=[];
checkans1();
checkans2();
checkans3();
checkans4();
checkans5();
checkans6();
checkans7();
var check1:Number=(useranswers.indexOf("ans1")+1);
var check2:Number=(useranswers.indexOf("ans2")+1);
var check3:Number=(useranswers.indexOf("ans3")+1);
var checklength:Number=useranswers.length;
var combined:Number=(check1+check2+check3)
rightans();
checkwrong();
function checkwrong(){
if (combined<=0){
trace("all wrong")
wrong.text="all of your answers are wrong";
function rightans(){
if(combined==6&&checklength==3){
trace("correct");
right.text="Correct";
}else if(check1>0 && check2>0 && check3>0){
trace("you are correct but..");
right.text="you are correct but..";
}else if(check1>0&&check2>0||check3>0&&check2>0||check1>0&&check3>0){
trace("you have two correct answers");
right.text="you have two correct answers";
}else if(check1>0||check2>0||check3>0){
trace("you have one correct answer");
right.text="you have one correct answer";
if(combined==6 && checklength==4){
trace("you have one wrong answer picked");
wrong.text="you have one wrong answer picked";
}else if(combined==6 && checklength==5){
trace("you have two wrong answers picked");
wrong.text="you have two wrong answers picked";
}else if(combined==6 && checklength==6){
trace("you have three wrong answers picked");
wrong.text="you have three wrong answers picked";
}else if(combined==6 && checklength==7){
trace("you have four wrong answers picked");
wrong.text="you have four wrong answers picked";
function checkans1(){
if ((ans1.hitTestObject(target1)==true)){
useranswers.push("ans1");
trace(useranswers);
function checkans2(){
if ((ans2.hitTestObject(target1)==true)){
useranswers.push("ans2");
trace(useranswers);
function checkans3(){
if ((ans3.hitTestObject(target1)==true)){
useranswers.push("ans3");
trace(useranswers);
function checkans4(){
if ((ans4.hitTestObject(target1)==true)){
useranswers.push("ans4");
trace(useranswers);
function checkans5(){
if ((ans5.hitTestObject(target1)==true)){
useranswers.push("ans5");
trace(useranswers);
function checkans6(){
if ((ans6.hitTestObject(target1)==true)){
useranswers.push("ans6");
trace(useranswers);
function checkans7(){
if ((ans7.hitTestObject(target1)==true)){
useranswers.push("ans7");
trace(useranswers);There are a number of ways you could improve that code. Here are a few..
1) Use of "this" the way you have used it is unnecessary.
2) All nut one set of your pickMe and dropMe functions are unnecessary and one of any one of them could be shared by all the ans objects
3) when using a boolean in a conditional test it is unnecessqary to use == true or == false. A conditionalk evaluates the boolean result oif whatever it contains, so you only need the part that generates the boolean result *ex: if(ans7.hitTestObject(target1)){...
4) Your evaluations at the end could probably all be reduce to testing within the dropMe function by assigning a value to each ans object (1,2,3...)
Maybe you are looking for
-
Change Management and Test Workbench for documentation
Hi, I would like some clarification on the association between change requests and test workbench. I'm going through scenarios such as creating a maintenance project, creating a task list and service message and then creating a transport request. Dur
-
Initial Load of IS-U business partners to CRM - bdoc error
Hi Gurus, i try to do an initial download from R/3 IS-U to CRM. Several objects from customizing have already been downloaded successfully. When downloading the business partners i get a bdoc error message for every single BP saying that 'business pa
-
Possible to install second hard drive in Pavillion p6110f
Is it possible to install a second hard drive, 1TB Seagate, into the expansion slot on my Pavillion p6110f?? This question was solved. View Solution.
-
Revision: 13535 Revision: 13535 Author: [email protected] Date: 2010-01-15 14:45:38 -0800 (Fri, 15 Jan 2010) Log Message: Part 1 of fixing line endings in AS and MXML files so that line numbers are correct while debugging. We've got a widesprea
-
Someone please help....All of my songs were deleted from both my Libray and my ipod.... I see a "old Library" file in my itunes folder under "My Music" folder in "my Documents"....I've tried importing and copy paste....but nothing is working to get t