《面向对象程序设计(java)》第六周学习总结

第一部分:理论知识

1)类、超类和子类
2)Object:所有类的超类
3)泛型数组列表
4)对象包装器和自动打包
5)参数数量可变的方法
6)枚举类
7)继承设计的技巧


第二部分:实验部分

继承定义与使用《代码测试和示例程序的注释》

1、实验目的与要求

(1) 理解继承的定义;

(2) 掌握子类的定义要求

(3) 掌握多态性的概念及用法;

(4) 掌握抽象类的定义及用途;//不能创建自己的对象,特殊类

(5) 掌握类中4个成员访问权限修饰符的用途;//public和private,

(6) 掌握抽象类的定义方法及用途;

(7)掌握Object类的用途及常用API;//最顶层的类,

(8) 掌握ArrayList类的定义方法及用法;//预定一类

(9) 掌握枚举类定义方法及用途。//预定一类


2、实验内容和步骤

实验1 导入第5章示例程序,测试并进行代码注释。

测试程序1:

•   在elipse IDE中编辑、调试、运行程序5-1 (教材152页-153页) ;

•   掌握子类的定义及用法;

•    结合程序运行结果,理解并总结OO风格程序构造特点,理解Employee和Manager类的关系子类的用途,并在代码中添加注释。

  1. 1 package inheritance;
  2. 2
  3. 3 /**
  4. 4 * This program demonstrates inheritance.
  5. 5 * @version 1.21 2004-02-21
  6. 6 * @author Cay Horstmann
  7. 7 */
  8. 8 public class ManagerTest
  9. 9 {
  10. 10 public static void main(String[] args)
  11. 11 {
  12. 12 // 创建一个Manager类对象;
  13. 13 Manager boss = new Manager("Carl Cracker", 80000, 1987, 12, 15);
  14. 14 boss.setBonus(5000);
  15. 15
  16. 16 Employee[] staff = new Employee[3]; //定义一个雇员数组;
  17. 17
  18. 18 // 用管理者和雇员对象填充数组;
  19. 19
  20. 20 staff[0] = boss;
  21. 21 staff[1] = new Employee("Harry Hacker", 50000, 1989, 10, 1);
  22. 22 staff[2] = new Employee("Tommy Tester", 40000, 1990, 3, 15);
  23. 23
  24. 24 // 输出所有雇员对象的信息;
  25. 25 for (Employee e : staff)
  26. 26 System.out.println("name=" + e.getName() + ",salary=" + e.getSalary());
  27. 27
  28. 28 }
  29. 29 } 
  1. package inheritance;
  2. 2
  3. 3 import java.time.*;
  4. 4
  5. 5 public class Employee
  6. 6 {
  7. 7 //定义Employee属性;
  8. 8 private String name;
  9. 9 private double salary;
  10. 10 private LocalDate hireDay;
  11. 11 //构造Employee对象,及初始化其属性,
  12. 12 public Employee(String name, double salary, int year, int month, int day)
  13. 13 {
  14. 14 this.name = name;
  15. 15 this.salary = salary;
  16. 16 hireDay = LocalDate.of(year, month, day);
  17. 17 }
  18. 18 //name属性访问器
  19. 19 public String getName()
  20. 20 {
  21. 21 return name;
  22. 22 }
  23. 23 //Salary属性访问器;
  24. 24 public double getSalary()
  25. 25 {
  26. 26 return salary;
  27. 27 }
  28. 28 //HireDay属性访问器
  29. 29 public LocalDate getHireDay()
  30. 30 {
  31. 31 return hireDay;
  32. 32 }
  33. 33 //raiseSalary方法;
  34. 34 public void raiseSalary(double byPercent)
  35. 35 {
  36. 36 double raise = salary
  37. 37 salary +=raise
  38. 38 } 
  1. 1 package inheritance;
  2. 2
  3. 3 public class Manager extends Employee//定义新类Manager是Employee的子类;
  4. 4 {
  5. 5 private double bonus;//子类独有属性;
  6. 6
  7. 7 /**
  8. 8 * @param name the employee's name
  9. 9 * @param salary the salary
  10. 10 * @param year the hire year
  11. 11 * @param month the hire month
  12. 12 * @param day the hire day
  13. 13 */
  14. 14 //构造Manager对象并初始化其属性;super直接调用父类参数,name,salary, year, month, day,无返回值;
  15. 15
  16. 16 public Manager(String name, double salary, int year, int month, int day)
  17. 17 {
  18. 18 super(name, salary, year, month, day);
  19. 19 bonus = 0; //Manager独有属性并初始化;
  20. 20 }
  21. 21 //Salary属性访问器,
  22. 22 public double getSalary()
  23. 23 {
  24. 24 //父类中的方法语句在子类中被重写成“独有方法”;
  25. 25 double baseSalary = super.getSalary();
  26. 26 return baseSalary + bonus;
  27. 27 }
  28. 28 //Bonus属性更改器;
  29. 29 public void setBonus(double b)
  30. 30 {
  31. 31 bonus = b;
  32. 32 }
  33. 33 }

实验结果截图: 


测试程序2:

•   编辑、编译、调试运行教材PersonTest程序(教材163页-165页);

•    掌握超类的定义及其使用要求;

•   掌握利用超类扩展子类的要求;

•    在程序中相关代码处添加新知识的注释。

  1. package abstractClasses;
  2.  
  3. /**
  4. * This program demonstrates abstract classes.
  5. * @version 1.01 2004-02-21
  6. * @author Cay Horstmann
  7. */
  8. public class PersonTest
  9. {
  10. public static void main(String[] args)
  11. {
  12. Person[] people = new Person[2];
  13.  
  14. // 用学生和雇员对象填充People数组;
  15. people[0] = new Employee("Harry Hacker", 50000, 1989, 10, 1);
  16. people[1] = new Student("Maria Morris", "computer science");
  17.  
  18. //输出所有Person对象的名称和描述;
  19.  
  20. for (Person p : people)
    System.out.println(p.getName() + ", " + p.getDescription());
    }
    }
  1. package abstractClasses;
  2.  
  3. public abstract class Person //定义抽象类型Person;
  1. {
    public abstract String getDescription();
    private String name;
    public Person(String name) {
  2.  
  3. this.name = name;
    }
    //Name属性访问器;
    public String getName() {
  4.  
  5. return name;
    }
    }
  1. package abstractClasses;
  2.  
  3. import java.time.*;
  4.  
  5. public class Employee extends Person //定义新类Employee是Person的子类
  6. {
    //定义属性;
  1. private double salary;
  2.  
  3. private LocalDate hireDay;
    public Employee(String name, double salary, int year, int month, int day) {
  4.  
  5. super(name); //调用父类方法;
  6.  
  7. this.salary = salary;//this代替当前对象;
    hireDay = LocalDate.of(year, month, day);//LocalDate方法;
    }
    //Salary属性访问器
    public double getSalary()
    {
  8.  
  9. return salary;
    }
  10.  
  11. public LocalDate getHireDay()
    {
    return hireDay;
    }
    //Description属性访问器,String类型;
    public String getDescription()
    {
  12.  
  13. return String.format("an employee with a salary of $%.2f", salary);
    }
    //Employee类独有方法;
    public void raiseSalary(double byPercent)
    {
    //计算语句;
    double raise = salary * byPercent / 100; salary += raise;
    }
    }
  1. package abstractClasses;
  2.  
  3. public class Student extends Person//子类Student继承父类Person;
  4. {
  5. private String major;
  6.  
  7. /**
  8. * @param nama the student's name
  9. * @param major the student's major
  10. */
  11. public Student(String name, String major)
  12. {
  13. // 将name传递给父类构造函数;
  14. super(name);
  15. this.major = major;
  16. }
  17.  
  18. public String getDescription()
  19. {
  20. return "a student majoring in " + major;
  21. }
  22. }

运行结果如下:


测试程序3:

•   编辑、编译、调试运行教材程序5-8、5-9、5-10,结合程序运行结果理解程序(教材174页-177页);

•  掌握Object类的定义及用法;

•  在程序中相关代码处添加新知识的注释。

  1. package equals;
  2.  
  3. /**
  4. * This program demonstrates the equals method.
  5. * @version 1.12 2012-01-26
  6. * @author Cay Horstmann
  7. */
  8. public class EqualsTest
  9. {
  10. public static void main(String[] args)
  11. {
  12. Employee alice1 = new Employee("Alice Adams", 75000, 1987, 12, 15);
  13. Employee alice2 = alice1;
  14. Employee alice3 = new Employee("Alice Adams", 75000, 1987, 12, 15);
  15. Employee bob = new Employee("Bob Brandson", 50000, 1989, 10, 1);
  16.  
  17. System.out.println("alice1 == alice2: " + (alice1 == alice2));
  18.  
  19. System.out.println("alice1 == alice3: " + (alice1 == alice3));
  20.  
  21. System.out.println("alice1.equals(alice3): " + alice1.equals(alice3));
  22.  
  23. System.out.println("alice1.equals(bob): " + alice1.equals(bob));
  24.  
  25. System.out.println("bob.toString(): " + bob);
  26.  
  27. Manager carl = new Manager("Carl Cracker", 80000, 1987, 12, 15);
  28. Manager boss = new Manager("Carl Cracker", 80000, 1987, 12, 15);
  29. boss.setBonus(5000);
  30. System.out.println("boss.toString(): " + boss);
  31. System.out.println("carl.equals(boss): " + carl.equals(boss));
  32. System.out.println("alice1.hashCode(): " + alice1.hashCode());
  33. System.out.println("alice3.hashCode(): " + alice3.hashCode());
  34. System.out.println("bob.hashCode(): " + bob.hashCode());
  35. System.out.println("carl.hashCode(): " + carl.hashCode());
  36. }
  37. }
  1. package equals;
  2.  
  3. import java.time.*;
  4. import java.util.Objects;
  5.  
  6. public class Employee
  7. {
  8. private String name;
  9. private double salary;
  10. private LocalDate hireDay;
  11.  
  12. public Employee(String name, double salary, int year, int month, int day)
  13. {
  14. this.name = name;
  15. this.salary = salary;
  16. hireDay = LocalDate.of(year, month, day);
  17. }
  18.  
  19. public String getName()
  20. {
  21. return name;
  22. }
  23.  
  24. public double getSalary()
  25. {
  26. return salary;
  27. }
  28.  
  29. public LocalDate getHireDay()
  30. {
  31. return hireDay;
  32. }
  33.  
  34. public void raiseSalary(double byPercent)
  35. {
  36. double raise = salary * byPercent / 100;
  37. salary += raise;
  38. }
  39.  
  40. public boolean equals(Object otherObject)
  41. {
  42. //快速检查对象是否相同
  43. if (this == otherObject) return true;
  44.  
  45. //如果显示参数为null,则必须返回false;
  46. if (otherObject == null) return false;
  47.  
  48. // 如果这些 类不匹配,他们不相等。
  49. if (getClass() != otherObject.getClass()) return false;
  50.  
  51. // 现在我们知道另一个对象是非空雇员;
  52. Employee other = (Employee) otherObject;
  53.  
  54. //测试字段是否具有相同的值;
  55. return Objects.equals(name, other.name) && salary == other.salary && Objects.equals(hireDay, other.hireDay);
  56. }
  57.  
  58. public int hashCode()
  59. {
  60. return Objects.hash(name, salary, hireDay);
  61. }
  62. //toString方法;
  63. public String toString()
  64. {
  65. return getClass().getName() + "[name=" + name + ",salary=" + salary + ",hireDay=" + hireDay
  66. + "]";
  67. }
  68. }
  1. package equals;
  2.  
  3. public class Manager extends //Employee子类Manager继承父类Employee
  4. {
    // 定义属性;
  5. private double bonus;
  6.  
  7. public Manager(String name, double salary, int year, int month, int day)
  8. {
  9. super(name, salary, year, month, day);//调用父类参数,无返回值;
  10. bonus = 0;
  11. }
  12. //Salary属性访问器;
  13. public double getSalary()
  14. {
  15. double baseSalary = super.getSalary();
  16. return baseSalary + bonus;
  17. }
  18.  
  19. public void setBonus(double bonus)
  20. {
  21. this.bonus = bonus;
  22. }
  23.  
  24. public boolean equals(Object otherObject)
  25. {
  26. if (!super.equals(otherObject)) return false;
  27. Manager other = (Manager) otherObject;
  28. // 检查这个是否与其他是否属于同一类;
  29. return bonus == other.bonus;
  30. }
  31.  
  32. public int hashCode()
  33. {
  34. return java.util.Objects.hash(super.hashCode(), bonus);
  35. }
  36.  
  37. public String toString()
  38. {
  39. return super.toString() + "[bonus=" + bonus + "]";
  40. }
  41. }


测试程序4:

•   在elipse IDE中调试运行程序5-11(教材182页),结合程序运行结果理解程序;

•   掌握ArrayList类的定义及用法;

•    在程序中相关代码处添加新知识的注释。

  1. package arrayList;
  2.  
  3. import java.util.*;
  4.  
  5. /**
  6. * This program demonstrates the ArrayList class.
  7. * @version 1.11 2012-01-26
  8. * @author Cay Horstmann
  9. */
  10. public class ArrayListTest
  11. {
  12. public static void main(String[] args)
  13. {
  14. // 用雇员对象填充staff数组;
  15. ArrayList<Employee> staff = new ArrayList<>();
  16.  
  17. staff.add(new Employee("Carl Cracker", 75000, 1987, 12, 15));
  18. staff.add(new Employee("Harry Hacker", 50000, 1989, 10, 1));
  19. staff.add(new Employee("Tony Tester", 40000, 1990, 3, 15));
  20.  
  21. //把每个雇员的薪水提高5%;
  22. for (Employee e : staff)
  23. e.raiseSalary(5);
  24.  
  25. // 打印所有雇员对象的信息;
  26. for (Employee e : staff)
  27. System.out.println("name=" + e.getName() + ",salary=" + e.getSalary() + ",hireDay="
  28. + e.getHireDay());
  29. }
  30. }
  1. package arrayList;
  2.  
  3. import java.time.*;
  4.  
  5. public class Employee
  6. {
  7. private String name;
  8. private double salary;
  9. private LocalDate hireDay;
  10.  
  11. public Employee(String name, double salary, int year, int month, int day)
  12. {
    //注意this的用法;
  13. this.name = name;
  14. this.salary = salary;
  15. hireDay = LocalDate.of(year, month, day);
  16. }
  17.  
  18. public String getName()
  19. {
  20. return name;
  21. }
  22.  
  23. public double getSalary()
  24. {
  25. return salary;
  26. }
  27.  
  28. public LocalDate getHireDay()
  29. {
  30. return hireDay;
  31. }
  32.  
  33. public void raiseSalary(double byPercent)
  34. {
  35. double raise = salary * byPercent / 100;
  36. salary += raise;
  37. }
  38. }


测试程序5:

•   编辑、编译、调试运行程序5-12(教材189页),结合运行结果理解程序;

•   掌握枚举类的定义及用法;

•    在程序中相关代码处添加新知识的注释。

  1. package enums;
  2.  
  3. import java.util.*;
  4.  
  5. /**
  6. * This program demonstrates enumerated types.
  7. * @version 1.0 2004-05-24
  8. * @author Cay Horstmann
  9. */
  10. public class EnumTest
  11. {
  12. public static void main(String[] args)
  13. {
  1. System.out.print("Enter a size: (SMALL, MEDIUM, LARGE, EXTRA_LARGE) ");
  2. String input = in.next().toUpperCase();
  3. Size size = Enum.valueOf(Size.class, input);
  4. System.out.println("size=" + size);
  5. System.out.println("abbreviation=" + size.getAbbreviation());
  6. if (size == Size.EXTRA_LARGE)
  7. System.out.println("Good job--you paid attention to the _.");
  8. }
  9. }
  10.  
  11. enum Size
  12. {
  13. SMALL("S"), MEDIUM("M"), LARGE("L"), EXTRA_LARGE("XL");
  14.  
  15. private Size(String abbreviation) { this.abbreviation = abbreviation; }
  16. public String getAbbreviation() { return abbreviation; }
  17.  
  18. private String abbreviation;
  19. }


实验2:编程练习1

•   定义抽象类Shape:

属性:不可变常量double PI,值为3.14;

方法:public double getPerimeter();public double getArea())。

•   让Rectangle与Circle继承自Shape类。

•   编写double sumAllArea方法输出形状数组中的面积和和double sumAllPerimeter方法输出形状数组中的周长和。

•    main方法中

1)输入整型值n,然后建立n个不同的形状。如果输入rect,则再输入长和宽。如果输入cir,则再输入半径。
2) 然后输出所有的形状的周长之和,面积之和。并将所有的形状信息以样例的格式输出。
3) 最后输出每个形状的类型与父类型,使用类似shape.getClass()(获得类型),shape.getClass().getSuperclass()(获得父类型);

思考sumAllArea和sumAllPerimeter方法放在哪个类中更合适?

输入样例:

  1. 3
  2. rect
  3. 1 1
  4. rect
  5. 2 2
  6. cir
  7. 1

  

输出样例:

  1. 18.28
  2. 8.14
  3. [Rectangle [width=1, length=1], Rectangle [width=2, length=2], Circle [radius=1]]
  4. class Rectangle,class Shape
  5. class Rectangle,class Shape
  6. class Circle,class Shape
  1. package Attention;
  2.  
  3. import java.math.*;
  4. import java.util.*;
  5. import Attention.Shape;
  6. import Attention.Rectangle;
  7. import Attention.Circle;
  8.  
  9. public class sum
  10. {
  11.  
  12. public static void main(String[] args)
  13. {
  14. Scanner in = new Scanner(System.in);
  15. String rect = "rect";
  16. String cir = "cir";
  17. System.out.print("请输入形状个数:");
  18. int n = in.nextInt();
  19. Shape[] score = new Shape[n];
  20. for(int i=0;i<n;i++)
  21. {
  22. System.out.println("请输入形状类型 (rect or cir):");
  23. String input = in.next();
  24. if(input.equals(rect))
  25. {
  26. double length = in.nextDouble();
  27. double width = in.nextDouble();
  28. System.out.println("Rectangle["+"length:"+length+" width:"+width+"]");
  29. score[i] = new Rectangle(width,length);
  30. }
  31. if(input.equals(cir))
  32. {
  33. double radius = in.nextDouble();
  34. System.out.println("Circle["+"radius:"+radius+"]");
  35. score[i] = new Circle(radius);
  36. }
  37. }
  38. Shape c = new Shape();
  39. System.out.println(c.sumAllPerimeter(score));
  40. System.out.println(c.sumAllArea(score));
  41. for(Shape s:score)
  42. {
  43.  
  44. System.out.println(s.getClass()+", "+s.getClass().getSuperclass());
  45. }
  46. }
  47.  
  48. public double sumAllArea(Shape core[])
  49. {
  50. double sum = 0;
  51. Object score;
  52. for(int i = 0;i<score.length;i++)
  53. sum+= score[i].getArea();
  54. return sum;
  55. }
  56.  
  57. public double sumAllPerimeter(Shape score[])
  58. {
  59. double sum = 0;
  60. for(int i = 0;i<score.length;i++)
  61. sum+= score[i].getPerimeter();
  62. return sum;
  63. }
  64.  
  65. }
  1. package Attention;
  2.  
  3. public abstract class Shape
  4. {
  5. double PI = 3.14;//不可变常量double PI,值为3.14;
  6. //方法:public double getPerimeter();public double getArea());
  7. public abstract double getPerimeter();
  8. public abstract double getArea();
  9. }
  1. package Attention;
  2.  
  3. public class Rectangle extends Shape //Rectangle继承自Shape类;
  4. {
  5. private double width;
  6. private double length;
  7. public Rectangle(double w,double l)
  8. {
  9. this.width=w;
  10. this.length=l;
  11. }
  12. public double getPerimeter()
  13. {
  14. double Perimeter = (width+length)*2;
  15. return Perimeter;
  16. }
  17. public double getArea()
  18. {
  19. double Area = width*length;
  20. return Area;
  21. }
  22.  
  23. public String toString()
  24. {
  25. return getClass().getName() + "[ width=" + width + "]"+ "[length=" + length + "]";
  26. }
  27. }
  1. package Attention;
  2.  
  3. public class Circle extends Shape//Circle继承自Shape类
  4. {
  5.  
  6. private double radius;
  7. public Circle(double r)
  8. {
  9. radius = r;
  10. }
  11. public double getPerimeter()
  12. {
  13. double Perimeter = 2*PI*radius;
  14. return Perimeter;
  15. }
  16. public double getArea()
  17. {
  18. double Area = PI*radius*radius;
  19. return Area;
  20. }
  21. public String toString()
  22. {
  23. return getClass().getName() + "[radius=" + radius + "]";
  24. }
  25. }

实验3: 编程练习2

编制一个程序,将身份证号.txt 中的信息读入到内存中,输入一个身份证号或姓名,查询显示查询对象的姓名、身份证号、年龄、性别和出生地。

  1. package Id;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.File;
  5. import java.io.FileInputStream;
  6. import java.io.FileNotFoundException;
  7. import java.io.IOException;
  8. import java.io.InputStreamReader;
  9. import java.util.ArrayList;
  10. import java.util.Scanner;
  11.  
  12. public class ID {
  13.  
  14. public static People findPeopleByname(String name) {
  15. People flag = null;
  16. for (People people : peoplelist) {
  17. if(people.getName().equals(name)) {
  18. flag = people;
  19. }
  20. }
  21. return flag;
  22.  
  23. }
  24.  
  25. public static People findPeopleByid(String id) {
  26. People flag = null;
  27. for (People people : peoplelist) {
  28. if(people.getnumber().equals(id)) {
  29. flag = people;
  30. }
  31. }
  32. return flag;
  33.  
  34. }
  35.  
  36. private static ArrayList<People> peoplelist;
  37.  
  38. public static void main(String[] args) {
  39. peoplelist = new ArrayList<People>();
  40. Scanner scanner = new Scanner(System.in);
  41. File file = new File("E:\\面向对象程序设计Java\\实验\\身份证号.txt");
  42. try {
  43. FileInputStream files = new FileInputStream(file);
  44. BufferedReader in = new BufferedReader(new InputStreamReader(files));
  45. String temp = null;
  46. while ((temp = in.readLine()) != null) {
  47.  
  48. Scanner linescanner = new Scanner(temp);
  49. linescanner.useDelimiter(" ");
  50. String name = linescanner.next();
  51. String number = linescanner.next();
  52. String sex = linescanner.next();
  53. String age = linescanner.next();
  54. String place = linescanner.nextLine();
  55. People people = new People();
  56. people.setName(name);
  57. people.setnumber(number);
  58. people.setage(age);
  59. people.setsex(sex);
  60. people.setplace(place);
  61. peoplelist.add(people);
  62.  
  63. }
  64. } catch (FileNotFoundException e) {
  65. System.out.println("文件未找到");
  66. e.printStackTrace();
  67. } catch (IOException e) {
  68. System.out.println("文件读取错误");
  69. e.printStackTrace();
  70. }
  71. boolean isTrue = true;
  72. while (isTrue) {
  73.  
  74. System.out.println("***********");
  75. System.out.println("1.按姓名查询");
  76. System.out.println("2.按身份证号查询");
  77. System.out.println("3.退出");
  78. System.out.println("***********");
  79. int nextInt = scanner.nextInt();
  80. switch (nextInt) {
  81. case 1:
  82. System.out.println("请输入姓名:");
  83. String peoplename = scanner.next();
  84. People person = findPeopleByname(peoplename);
  85. if (people != null) {
  86. System.out.println(" 姓名:"+
  1. person.getName() + " 身份证号:"+ person.getnumber() + " 年龄:"+ person.getage()+ " 性别:"+ person.getsex()+ " 地址:"+ person.getplace() ); } else { System.out.println("
  1. 此人不存在"); } break; case 2: System.out.println("请输入身份证号:"); String peopleid = scanner.next(); People person1 = findPeopleByid(peopleid); if (people1 != null) { System.out.println(" 姓名:"+person
  1. 1.getName()+ " 身份证号:"+ person1.getnumber()+ " 年龄:"+ person1.getage()+ " 性别:"+ person1.getsex()+ " 地址:"+ person1.getplace()); } else { System.out.println("此人不存在"); } break; case 3: isTrue = false; System.out.println("byebye!"); break; default: System.out.println("输入有误"); } } } }
  1. package Id;
  2.  
  3. public class Person{
  4.  
  5. private String name;
  6. private String number;
  7. private String age;
  8. private String sex;
  9. private String place;
  10.  
  11. public String getName()
  12. {
  13. return name;
  14. }
  15. public void setName(String name)
  16. {
  17. this.name = name;
  18. }
  19. public String getnumber()
  20. {
  21. return number;
  22. }
  23. public void setnumber(String number)
  24. {
  25. this.number = number;
  26. }
  27. public String getage()
  28. {
  29. return age;
  30. }
  31. public void setage(String age )
  32. {
  33. this.age = age;
  34. }
  35. public String getsex()
  36. {
  37. return sex;
  38. }
  39. public void setsex(String sex )
  40. {
  41. this.sex = sex;
  42. }
  43. public String getplace()
  44. {
  45. return place;
  46. }
  47. public void setplace(String place)
  48. {
  49. this.place = place;
  50. }
  51. }


第三部分:总结

上周实验课助教老师的详细讲解对我的来说有很大帮助,以及老师在课堂带领我们阅读代码 让我学到很多。总的来说,能力还是很低下,我意识到自己的自主学习能力比较差,这与自身素质方面有很大关系,希望我可以通过这次彻底的认识到自己的问题,提高自己的能力。

杨其菊201771010134《面向对象程序设计(java)》第六周学习总结的更多相关文章

  1. 201771010134杨其菊《面向对象程序设计java》第九周学习总结

                                                                      第九周学习总结 第一部分:理论知识 异常.断言和调试.日志 1.捕获 ...

  2. 201771010134杨其菊《面向对象程序设计java》第十周学习总结

    第8章泛型程序设计学习总结 第一部分:理论知识 主要内容:   什么是泛型程序设计                   泛型类的声明及实例化的方法               泛型方法的定义      ...

  3. 201771010134杨其菊《面向对象程序设计java》第八周学习总结

    第八周学习总结 第一部分:理论知识 一.接口.lambda和内部类:  Comparator与comparable接口: 1.comparable接口的方法是compareTo,只有一个参数:comp ...

  4. 201771010134杨其菊《面向对象程序设计(java)》第十六周学习总结

    第十六周学习总结 第一部分:理论知识 1. 程序是一段静态的代码,它是应用程序执行的蓝本.进程是程序的一次动态执行,它对应了从代码加载.执行至执行完毕的一个完整过程.操作系统为每个进程分配一段独立的内 ...

  5. 201771010134杨其菊《面向对象程序设计java》第十二周学习总结

    第十二周学习总结 第一部分:理论知识 内容概要: AWT与Swing简介:框架的创建:图形程序设计: 显示图像: 1.AWT组件: 2.Swing 组件层次关系 3 .AWT与Swing的关系:大部分 ...

  6. 201771010134杨其菊《面向对象程序设计java》第七周学习总结

    第七周学习总结 第一部分:理论知识 1.继承是面向对象程序设计(Object Oriented Programming-OOP)中软件重用的关键技术.继承机制使用已经定义的类作为基础建立新的类定义,新 ...

  7. 201871010132-张潇潇《面向对象程序设计(java)》第一周学习总结

    面向对象程序设计(Java) 博文正文开头 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cn ...

  8. 扎西平措 201571030332《面向对象程序设计 Java 》第一周学习总结

    <面向对象程序设计(java)>第一周学习总结 正文开头: 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 ...

  9. 杨其菊201771010134《面向对象程序设计Java》第二周学习总结

    第三章 Java基本程序设计结构 第一部分:(理论知识部分) 本章主要学习:基本内容:数据类型:变量:运算符:类型转换,字符串,输入输出,控制流程,大数值以及数组. 1.基本概念: 1)标识符:由字母 ...

  10. 201871010124 王生涛《面向对象程序设计JAVA》第一周学习总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://edu.cnblogs.com/campus/xbsf/ ...

随机推荐

  1. Spring Boot - 项目构建与解析

    构建 Maven 项目 通过官方的 Spring Initializr 工具来产生基础项目,访问 http://start.spring.io/ ,如下图所示,该页面提供了以Maven构建Spring ...

  2. linux SVN命令

    1.将文件checkout到本地目录 svn checkout path(path是服务器上的目录)   例如:svn checkout svn://192.168.1.1/pro/domain    ...

  3. 初识rt-thread

    bernard.xiong CEO 熊谱祥 env,提供编译构建环境.图形化系统配置及软件包管理功能 scons 是 RT-Thread 使用的编译构建工具,可以使用 scons 相关命令来编译 RT ...

  4. new 对象时的暗执行顺序

    为什么称为暗执行顺序,因为当我们在new 对象时,其不是简简单单的new一个完事,它要首先检查父类的,静态的,非静态的等代码,就好像我们结婚生孩子一样,要先到祖宗那里,公安局那里,左邻右舍那里,告诉他 ...

  5. PAT 甲级 1027 Colors in Mars (20 分)

    1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...

  6. 涨姿势:深入 foreach循环

    我们知道集合中的遍历都是通过迭代(iterator)完成的. 也许有人说,不一定非要使用迭代,如: List<String> list = new LinkedList<String ...

  7. 实验四:xl命令的常见子命令以及操作

    实验名称: xl命令的常见子命令以及操作 实验环境: 这里我们需要正常安装一台虚拟机,如下图: 我们这里以一台busybox为例,来进行这些简单的常见的操作: 实验要求: 这里我们准备了5个常见操作: ...

  8. oracle自定义函数返回结果集

    首先要弄两个type,不知道什么鬼: 1. create or replace type obj_table as object ( id ), name ), ) ) 2. create or re ...

  9. 【Linux】【Jenkins】配置过程中,立即构建时,maven找不到的问题解决方案

    在Linux环境下配置Jenkins执行时,发现不能执行Maven,这个比较搞了. A Maven installation needs to be available for this projec ...

  10. django之 基于queryset和双下划线的跨表查询

    前面篇随笔写的是基于对象的跨表查询:对象.objects.filter(...)  对象.关联对象_set.all(...)  -->反向 基于对象的跨表查询例如: book_obj= Book ...