Initial commit
This commit is contained in:
BIN
实验报告模板/JavaEE基础教程实验指导与习题解析.pdf
Normal file
BIN
实验报告模板/JavaEE基础教程实验指导与习题解析.pdf
Normal file
Binary file not shown.
13
实验报告模板/实验1-全部作业.txt
Normal file
13
实验报告模板/实验1-全部作业.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
实验指导书:
|
||||
1、P171页, 环境测试,要求如P172页,在Eclipse中新建项目以及Java文件,输入P172页(1)中的代码,运行程序,测试输出结果
|
||||
2、P172页,第4题(1),输入相应代码
|
||||
(1)直接运行,查看输出结果
|
||||
(2)在Eclipse的运行环境中输入2个参数,查看运行结果。
|
||||
得出结论与心得。
|
||||
3、P173页,第5题(写到实验报告)
|
||||
4、P175页,第1题,第2题(写到实验报告),第3题,
|
||||
5、P179页,编程题,第1题(写到实验报告)
|
||||
6、P9页,例2.1.3(写到实验报告)
|
||||
7、P9页,例2.1.4
|
||||
|
||||
|
||||
44
实验报告模板/实验报告4/BackAnimal.java
Normal file
44
实验报告模板/实验报告4/BackAnimal.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package ch04;
|
||||
|
||||
abstract class Animal{
|
||||
public abstract void eat(); //只有方法名,而没有方法体
|
||||
}
|
||||
class Dog extends Animal{
|
||||
private String name;
|
||||
public void setName(String name){
|
||||
this.name=name;
|
||||
}
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
public void eat(){
|
||||
System.out.println("小狗啃骨头啦");
|
||||
}
|
||||
}
|
||||
class Bird extends Animal{
|
||||
public void fly( ){
|
||||
System.out.println("小鸟飞呀飞呀");
|
||||
}
|
||||
public void eat( ){
|
||||
System.out.println("小鸟吃虫子啦");
|
||||
}
|
||||
}
|
||||
public class BackAnimal{
|
||||
public static void main( String args[ ] ){
|
||||
Animal a1=new Animal(); //1.该行代码可不可以执行?为什么?
|
||||
Animal an = new Dog( );
|
||||
an.eat( ); //2.该行代码输出什么?
|
||||
an=new Bird();
|
||||
an.eat(); //3.该行代码输出什么?
|
||||
Animal x1=new Dog();
|
||||
Animal x2=new Bird();
|
||||
print(x1); //4.以下2行代码输出什么?为什么?
|
||||
print(x2);
|
||||
|
||||
}
|
||||
public static void print(Animal a){
|
||||
a.eat();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
28
实验报告模板/实验报告4/ex4-2023.11.01版第4题分析/Sobject.java
Normal file
28
实验报告模板/实验报告4/ex4-2023.11.01版第4题分析/Sobject.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.ex4;
|
||||
|
||||
public class Sobject {
|
||||
private String name;
|
||||
private double weight; //ÖØÁ¿
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public double getWeight() {
|
||||
return weight;
|
||||
}
|
||||
public void setWeight(double weight) {
|
||||
this.weight = weight;
|
||||
}
|
||||
public Sobject(String name, double weight) {
|
||||
this.name = name;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public void print() {
|
||||
System.out.println("name:"+name+",weight:"+weight);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
28
实验报告模板/实验报告4/ex4-2023.11.01版第4题分析/Table.java
Normal file
28
实验报告模板/实验报告4/ex4-2023.11.01版第4题分析/Table.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.ex4;
|
||||
|
||||
public class Table extends Sobject{
|
||||
private double width; //宽度
|
||||
private double length; //长度
|
||||
private double height; //高度
|
||||
|
||||
//如果该类不写构造方法,系统会自动为 Table添加一个无参数的构造方法
|
||||
//在这个无参构造方法中,会自动调用Sobject类中的无参数的构造方法
|
||||
// public Table() {
|
||||
// super();
|
||||
//// super("abc",34.5);
|
||||
// }
|
||||
//
|
||||
public Table(String name,double weight,double width,double length,double height) {
|
||||
super(name, weight);
|
||||
this.width=width;
|
||||
this.length=length;
|
||||
this.height=height;
|
||||
|
||||
}
|
||||
public double area() {
|
||||
return width*length;
|
||||
}
|
||||
public void changeWeight(double w) {
|
||||
setWeight(w);
|
||||
}
|
||||
}
|
||||
15
实验报告模板/实验报告4/ex4-2023.11.01版第4题分析/Test.java
Normal file
15
实验报告模板/实验报告4/ex4-2023.11.01版第4题分析/Test.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.ex4;
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
Table table=new Table("A1", 23, 1.8, 2.3, 0.8);
|
||||
double area=table.area();
|
||||
table.changeWeight(45);
|
||||
System.out.println(area);
|
||||
System.out.println(table.getWeight());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
BIN
实验报告模板/实验报告4/实验报告模板-实验4 - 2023.11.01.doc
Normal file
BIN
实验报告模板/实验报告4/实验报告模板-实验4 - 2023.11.01.doc
Normal file
Binary file not shown.
BIN
实验报告模板/实验报告4/实验报告模板-实验4.doc
Normal file
BIN
实验报告模板/实验报告4/实验报告模板-实验4.doc
Normal file
Binary file not shown.
18
实验报告模板/实验报告4/实验讲课.txt
Normal file
18
实验报告模板/实验报告4/实验讲课.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
接口
|
||||
若类中的所有的方法都是抽象方法,并且没有成员变量----->接口
|
||||
|
||||
抽象类:可以有成员变量、可以有普通方法、可以有抽象方法
|
||||
接口:
|
||||
(1)没有成员变量,只有常量与抽象方法,接口中定义的所有方法都是抽象方法
|
||||
(2)即接口不可以直接创建象,接口必须通过派生子类来创建对象
|
||||
(3)接口中所有方法都必须在子类中重写。
|
||||
(4)接口中可以定义常量
|
||||
int footnum=2;<===>public final static int footnum=2;
|
||||
(5)接口可以多继承,1个类可以继承多个接口,但1个类只能继承1个父类
|
||||
|
||||
final,staic
|
||||
public final static int footernum=-1; //定义了静态、常量,可以通过类名调用
|
||||
public static int footernum=-1; //静态常量,该变量可以被类创建的所有对象共享,可以通过类名调用
|
||||
public final int footernum=-1; //常量,该常量,必须通过对象名来调用
|
||||
|
||||
设计1个用户,用户有用户名,密码属性,登录,注册(动作、方法)
|
||||
23
实验报告模板/实验报告6/p14/BusCard.java
Normal file
23
实验报告模板/实验报告6/p14/BusCard.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.p14;
|
||||
|
||||
public class BusCard {
|
||||
private float balance;
|
||||
public BusCard() {
|
||||
balance=0;
|
||||
}
|
||||
public float queryBalance() {
|
||||
return balance;
|
||||
}
|
||||
public void charge(float money) {
|
||||
balance=balance+money;
|
||||
}
|
||||
public void swipe(float money) throws CardException{
|
||||
if(balance<money) {
|
||||
CardException ex=new CardException("余额不足,无法刷卡,请尽快充值!");
|
||||
throw ex;
|
||||
}else {
|
||||
balance=balance-money;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
17
实验报告模板/实验报告6/p14/CardException.java
Normal file
17
实验报告模板/实验报告6/p14/CardException.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.p14;
|
||||
|
||||
public class CardException extends Exception{
|
||||
private String message;
|
||||
public CardException(String message) {
|
||||
this.message=message;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
22
实验报告模板/实验报告6/p14/Test.java
Normal file
22
实验报告模板/实验报告6/p14/Test.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.p14;
|
||||
|
||||
public class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//开卡
|
||||
BusCard card=new BusCard();
|
||||
//充值
|
||||
card.charge(2);
|
||||
//查询余额
|
||||
System.out.println("余额:"+card.queryBalance());
|
||||
|
||||
//刷卡
|
||||
try {
|
||||
card.swipe(5);
|
||||
System.out.println("刷卡成功!您的余额:"+card.queryBalance());
|
||||
} catch (CardException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
BIN
实验报告模板/实验报告6/实验报告模板-实验6.doc
Normal file
BIN
实验报告模板/实验报告6/实验报告模板-实验6.doc
Normal file
Binary file not shown.
BIN
实验报告模板/实验报告模板-实验1.doc
Normal file
BIN
实验报告模板/实验报告模板-实验1.doc
Normal file
Binary file not shown.
BIN
实验报告模板/实验报告模板-实验2-2023.10.18.doc
Normal file
BIN
实验报告模板/实验报告模板-实验2-2023.10.18.doc
Normal file
Binary file not shown.
BIN
实验报告模板/实验报告模板-实验2.doc
Normal file
BIN
实验报告模板/实验报告模板-实验2.doc
Normal file
Binary file not shown.
BIN
实验报告模板/实验报告模板-实验3.doc
Normal file
BIN
实验报告模板/实验报告模板-实验3.doc
Normal file
Binary file not shown.
BIN
实验报告模板/实验报告模板-实验5.doc
Normal file
BIN
实验报告模板/实验报告模板-实验5.doc
Normal file
Binary file not shown.
BIN
实验报告模板/实验报告模板-实验7.doc
Normal file
BIN
实验报告模板/实验报告模板-实验7.doc
Normal file
Binary file not shown.
BIN
实验报告模板/实验报告模板-实验8.doc
Normal file
BIN
实验报告模板/实验报告模板-实验8.doc
Normal file
Binary file not shown.
Reference in New Issue
Block a user