2011年内蒙古工业大学复习题编程题答案

1.

public class Patient { private String name; private char sex; private int age; private float weight; private boolean allergies; public String getName() { return name;

}

public void setName(String name) { http://www.wendangwang.com = name; }

public char getSex() { return sex; }

public void setSex(char sex) { this.sex = sex; }

public int getAge() { return age; }

public void setAge(int age) { this.age = age; }

public float getWeight() { return weight; }

public void setWeight(float weight) { this.weight = weight; }

public boolean isAllergies() { return allergies; }

public void setAllergies(boolean allergies) { this.allergies = allergies; }

public Patient(String name, char sex, int age, float weight,

boolean allergies) { super();

http://www.wendangwang.com = name; this.sex = sex; this.age = age; this.weight = weight; this.allergies = allergies;

}

public String toString() {

return "Patient name=" + name + ", sex="+ sex + ", age=" + age

+ ", weight=" + weight + ",

allergies=" + allergies + "\n";

}

public boolean equals(Object obj) { if (this == obj) return true; if (obj == null)

return false; Patient other = (Patient) obj;

if

((!name.equals(http://www.wendangwang.com))&&sex!=other.sex&&age!=other.age) return false; else

return true; }

}

public class PatientTest { public static void main(String[] args){ Patient p1=new Patient("wang",'f',22,98.0f,false); Patient p2=new

Patient("zhang",'m',33,130.0f,true);

System.out.println(p1+"\n"+p2); }

}

2.

import java.sql.*; public class SqlUpdate { private static String DDriver="com.mysql.jdbc.Driver";

private static String

DURL="jdbc:sqlserver://127.0.0.1:1433:jsj09";

public static void main(String[] args){ Connection conn=null; Statement st=null; int try{ try { Class.forName(DDriver); } catch (ClassNotFoundException e) {

e.printStackTrace();

}

conn=DriverManager.getConnection(DURL,"sa","123456");

String sql="UPDATE classname='计算机09班' WHERE stuid='20091010*'";

st=conn.createStatement();

rs=st.executeUpdate(sql);

Word文档免费下载Word文档免费下载:2011年内蒙古工业大学复习题编程题答案 (共3页,当前第1页)

你可能喜欢

  • 内蒙古工业大学试卷
  • 内蒙古工业大学计算机网络
  • 内蒙古工业大学本科毕业论文
  • 大学毕业生就业推荐表
  • 大学毕业论文格式
  • 暖通空调毕业设计
  • 余热锅炉
  • 内蒙古大学论文

2011年内蒙古工业大学复习题编程题答案相关文档

最新文档

返回顶部