当前位置:编程学习 > JAVA >>

请Java高手帮我看一下这个代码的错误:

import java.applet.Applet; import java.awt.*; //* E-Store //* 如果所购商品总额大于$100,免费运送,否则加 $2.00的运送费。 public class EStore extends Applet{ //常量 private static final float COAT_PRICE = 50.00f;//第一商品的 private static final float SHIRT_PRICE = 25.50f;//第二个商品的 private static final float SHOES_PRICE = 39.99f;//3 private static final float HAT_PRICE = 10.00f;//4 private static final String TOTAL_STR = "Your current total = $";//商品总额 private static final String RESET = "RESET";// private static final String PURCHASE = "Purchase Item"; private static final String REMOVE = "Remove Item"; private static final String CHECK_OUT = "Check out"; private static final String COAT_STR = "WINTER COAT"; private static final String SHIRT_STR = "LONG SLEEVE SHIRT"; private static final String SHOES_STR = "LEATHER SHOE"; private static final String HAT_STR = "UofA CAP"; private static final String WELCOME = "Welcome to CMPUT 114 E-Store"; private static final int MAX_ITEMS = 5; // 购物篮中最多能容纳的商品件数 public void init() { float COAT_PRICE,SHIRT_PRICE,SHOES_PRICE,HAT_PRICE; String TOTAL_STR,RESET,PURCHASE,REMOVE,CHECK_OUT,COAT_STR, SHIRT_STR,SHOES_STR,HAT_STR,WELCOME; int MAX_ITEMS; makeButton();makewelcomeLabel();makelastl(); makemassageLabel();maketotalLabel(); } private void makewelcomeLabel() { welcomeLabel c1=new welcomeLabel(); c1.setvisible(true); c1.setSize(50,20); c1.setlocation(100,100); this.add(c1); } private void makelastl() { last1 d1=new Last1(); d1.setvisible(true); d1.setsize(70,30); d1.setlocation(100,100); this.add(d1); } private void makeButton() { Button b1=new Button("添加"); b1.setVisible(true); b1.setSize(100, 10); b1.setLocation(100, 100); this.add(b1); Button b2=new Button("结账"); b2.setVisible(true); b2.setSize(100, 10); b2.setLocation(100, 100); this.add(b2); Button b3=new Button("删除"); b3.setVisible(true); b3.setSize(100, 10); b3.setLocation(100, 100); this.add(b3); Button b4=new Button("重置"); b4.setVisible(true); b4.setSize(100, 10); b4.setLocation(100, 100); this.add(b4); } private void makemassageLabel() { massageLabel c1=new massageLabel(); c1.setvisible(true); c1.setSize(50,20); c1.setlocation(100,100); this.add(c1); } private void maketotalLabel() { totalLabel a1=new totalLabel(); a1.setvisible(true); a1.setSize(50,20); a1.setlocation(100,100); this.add(a1); } }
答案:你也没有说有什么错啊
其他:你代码没给全吧,但看你上面的那段代码,就初始化的时候把几个私有常量又重新定义了几个相同名称的变量,没什么意思,其他的最多也就是坐标问题 1.
php 在申明变量时不能强制要求数据类型。
private static int $length = 0;
改成
private static $length = 0;
//注:private等关键字的封闭,在php5之后才实现。
以下如同样定义数据类型的问题,将不在缀述.如下面的String,去掉即可.
2.
if(!empty($staffCd){
   return $result;
  }
这要会导致$staffCd非空的话就会返回,而根据function的本意是要用到$staffCd的值的,建议把!去掉。这里并不是程序错误,我怀疑是逻辑错误。如果逻辑上没有错误,请忽略这条。
3.
String[] $staff = split('-',$staffCd);
改为
$staff = explode('-',$staffCd);
详细请查php5 api;
4.
$result += $temp->charAt(2);
改成
$result .= $temp[2];
其他类似地方改法相同。php中字符串的拼接用.号,而不是+号。
5。
 $result = String->valueOf($numStr + 10);
理论上改成:
 $result = intval($numStr ."10");
其他地方类似用strval intval等php5 api内的方法代替java api中的方法。
这样感觉逻辑上还是不通。感觉你的java代码本身就有问题。
建议改成
 $result = intval($numStr) + 10;



可能就这么多了吧。欢迎别人补充
 

上一个:泛型对Java工程师的重要性
下一个:java 模糊查询的问题,请大侠支招

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,