guyanqing 1 năm trước cách đây
mục cha
commit
9c31055675

+ 39 - 0
src/main/java/com/sf/day14/Person.java

@@ -0,0 +1,39 @@
+package com.sf.day14;
+
+public class Person {
+    private Integer id;
+
+    private String name;
+
+    public Person() {
+    }
+
+    public Person(Integer id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String toString() {
+        return "Person{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                '}';
+    }
+}

+ 268 - 0
src/main/java/com/sf/day14/Test01.java

@@ -0,0 +1,268 @@
+package com.sf.day14;
+
+import org.junit.Test;
+
+import javax.swing.*;
+import java.security.PublicKey;
+import java.util.*;
+import java.util.function.Predicate;
+
+public class Test01 {
+   @Test
+    public void t1(){
+       // arrayList 是Collection接口的子接口的典型实现类之一
+       Collection collection = new ArrayList();  //多态
+       collection.add("小李广");
+       collection.add("扫地僧");
+       collection.add("石破天");
+       collection.add("石破天");
+      System.out.println(collection);
+
+      //addAll
+       Collection collection1 = new ArrayList();
+       collection1.add("扫地僧1");
+       collection1.add("石破天1");
+       collection.addAll(collection1);
+       System.out.println(collection);
+       System.out.println(collection1);
+       collection1.addAll(collection);
+       System.out.println(collection);
+       System.out.println(collection1);
+       //判断集合中元素的个数
+       System.out.println(collection.size());
+   }
+
+
+   @Test
+   public void t2(){
+       Collection<Integer> coll = new ArrayList();
+       //当前集合为空  返回true   否则返回false
+       System.out.println("coll在添加元素之前,isEmpty = " + coll.isEmpty());
+//       coll.add(Integer.valueOf("A"));
+       //string类型转换成integer类型   Integer.valueof()
+//       coll.add("扫地僧");
+//       coll.add("佛地魔");
+       //当前集合中的元素个数
+       System.out.println("coll的元素个数" + coll.size());
+
+       System.out.println("coll在添加元素之后,isEmpty = " + coll.isEmpty());
+
+       System.out.println("当前集合是否包含 小李广"+coll.contains("小李广"));
+       System.out.println("当前集合是否包含 小李"+coll.contains("小李"));
+
+
+       Collection collection = new ArrayList();
+       collection.add("小李广");
+       collection.add("扫地僧");
+       collection.add("石破天");
+       collection.add("佛地魔");
+       collection.add("佛地魔");
+
+       System.out.println("coll集合中是否包含collection集合"+coll.containsAll(collection));
+       System.out.println(collection.equals(coll));
+
+       System.out.println("=================================");
+//       boolean remove = collection.remove("佛地魔");
+//       System.out.println(remove);
+//       System.out.println(collection);
+//       collection.clear();
+//       System.out.println("判断当前集合是否为空"+collection.isEmpty());
+//       System.out.println(collection);  //[]
+
+//       collection.removeAll(coll);  //从当前集合中删除所有与coll集合中相同的元素
+//       System.out.println(collection);
+
+       //从当前集合中删除两个集合中不同的元素,使得当前集合仅保留与coll集合中的元素相同的元素,即当前集合中仅保留两个集合的交集;保留两个集合中交集的元素。
+//       boolean b = collection.retainAll(coll);
+//       System.out.println(collection);
+
+       System.out.println(collection);
+       List<String> list = new ArrayList<>();
+       list.add("zhangsan");
+       list.add("lisi");
+       list.add("wangwu");
+       System.out.println(list.size());
+       String s = list.get(0);
+       System.out.println(s);
+       list.set(1,"zhanghsan33");
+       System.out.println(list.get(1));
+
+       //第一种方法遍历
+       for (int i = 0;i<list.size();i++){
+           String s1 = list.get(i);
+           System.out.println(s1);
+       }
+       System.out.println("========");
+       //    iter
+       for (String s1 : list) {
+           System.out.println(s1);
+       }
+   }
+
+   @Test
+   public void t(){
+       Collection collection = new ArrayList();
+       collection.add("小李广");
+       collection.add("扫地僧");
+       collection.add("石破天");
+       collection.add("佛地魔");
+       collection.add("佛地魔1");
+       collection.add("佛地魔2");
+       collection.add("佛地魔3");
+       //将集合转换成数组
+       Object[] objects = collection.toArray();
+       System.out.println(objects);
+       for (Object object : objects) {
+           System.out.println(object);
+       }
+
+       //数组转换成集合的方法
+       List<Object> objects1 = Arrays.asList(objects);
+       String o1 = (String) objects1.get(1);
+       System.out.println("==========="+o1);
+       for (Object o : objects1) {
+           System.out.println(o);
+       }
+   }
+
+   @Test
+   public void t4(){
+       //字符串数组
+       List<String> listString = new ArrayList<>();
+       listString.add(1,"zhangsan");
+       listString.add(0,"lisa");
+
+
+//       List<Object> obj = new ArrayList<>();
+//       obj.add("zahngsan");
+//       obj.add(12);
+//       obj.add(new String());
+
+       List<Person> personList = new ArrayList<>();
+       personList.add(new Person(12,"name"));
+       personList.add(new Person(12,"name"));
+       personList.add(new Person(12,"name"));
+       System.out.println(personList);
+
+       /**
+        *
+        */
+       List<Worker> workerList  = new ArrayList<>();
+//       workerList.add(new Worker())
+   }
+
+
+   @Test
+   public void t5(){
+       Collection<Integer> collection = new ArrayList<>();
+       for (int i = 0 ;i<20;i++){
+           collection.add(i+1);
+       }
+
+       //第一种遍历的方式
+//       for (Integer integer : collection) {
+//           System.out.println(integer);
+//       }
+
+       Iterator<Integer> iterator = collection.iterator();
+//       System.out.println(iterator.next());
+//       System.out.println(iterator.next());
+//       System.out.println(iterator.next());
+//       System.out.println(iterator.next());
+       while (iterator.hasNext()){ //判断是否有下一个元素
+           System.out.println(iterator.next());   //获取下一个元素
+       }
+   }
+
+   @Test
+   public void t6(){
+       List<String> list = new ArrayList<>();
+       list.add("abc");
+       list.add("afg");
+       list.add("amf");
+       list.add("mfg");
+       list.add("age");
+       list.add("ofh");
+
+       Iterator<String> iterator = list.iterator();
+       while (iterator.hasNext()){
+           String next = iterator.next();
+           if(next.contains("a")){
+               iterator.remove();
+           }
+           System.out.println(next);
+       }
+       System.out.println(list);
+   }
+
+   @Test
+   public void t7(){
+       List<String> listString = new ArrayList<>();
+       listString.add("zhangsan");
+       listString.add("lisa");
+       Iterator<String> iterator = listString.iterator();
+       while (iterator.hasNext()){
+           String next = iterator.next();
+           if(next.equals("lisa")){
+               iterator.remove();
+           }
+       }
+
+       for (String s : listString) {
+           System.out.println(listString);
+       }
+   }
+
+   @Test
+   public void t8(){
+       Collection coll = new ArrayList();
+       coll.add(1);
+       coll.add(2);
+       coll.add(3);
+       coll.add(4);
+       coll.add(5);
+       coll.add(6);
+       Iterator iterator = coll.iterator();
+       while (iterator.hasNext()){
+           Integer next = (Integer) iterator.next();
+           if(next%2==0){
+               iterator.remove();
+           }
+       }
+       System.out.println(coll);
+   }
+
+   @Test
+   public void t9(){
+       Collection coll = new ArrayList();
+       coll.add("小李广");
+       coll.add("扫地僧");
+       coll.add("石破天");
+       coll.add("佛地魔");
+       System.out.println(coll);
+        coll.removeIf(new Predicate() {
+            @Override
+            public boolean test(Object o) {
+                String str = (String) o;
+                boolean flag = str.contains("小");
+                return flag;
+            }
+        });
+       System.out.println(coll);
+   }
+
+   @Test
+   public void t10(){
+       List<String> list  =  new ArrayList<>();
+       list.add("Hello");
+       list.add("World");
+       list.add("Hello");
+       list.add("Learn");
+       list.remove("Hello");
+       list.remove(0);
+       for (String s : list) {
+           System.out.println(s);
+       }
+   }
+
+}

+ 108 - 0
src/main/java/com/sf/day14/Worker.java

@@ -0,0 +1,108 @@
+package com.sf.day14;
+
+public class Worker {
+    private String zw;    //职位
+    private Double salary;  //工资
+    /**
+     * 国家    省  市   区  街道  详细地址
+     * address   国家    省  市   区  街道  详细地址
+     */
+    private String address;  //地点
+    private Double  workTime;  //工作经验
+    private Integer   xl;  //学历
+    private String  gsName;
+    private Integer gsLevel;
+    private Integer numberPerson;
+
+    public Worker() {
+    }
+
+    public Worker(String zw, Double salary, String address, Double workTime, Integer xl, String gsName, Integer gsLevel, Integer numberPerson) {
+        this.zw = zw;
+        this.salary = salary;
+        this.address = address;
+        this.workTime = workTime;
+        this.xl = xl;
+        this.gsName = gsName;
+        this.gsLevel = gsLevel;
+        this.numberPerson = numberPerson;
+    }
+
+    public String getZw() {
+        return zw;
+    }
+
+    public void setZw(String zw) {
+        this.zw = zw;
+    }
+
+    public Double getSalary() {
+        return salary;
+    }
+
+    public void setSalary(Double salary) {
+        this.salary = salary;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public Double getWorkTime() {
+        return workTime;
+    }
+
+    public void setWorkTime(Double workTime) {
+        this.workTime = workTime;
+    }
+
+    public Integer getXl() {
+        return xl;
+    }
+
+    public void setXl(Integer xl) {
+        this.xl = xl;
+    }
+
+    public String getGsName() {
+        return gsName;
+    }
+
+    public void setGsName(String gsName) {
+        this.gsName = gsName;
+    }
+
+    public Integer getGsLevel() {
+        return gsLevel;
+    }
+
+    public void setGsLevel(Integer gsLevel) {
+        this.gsLevel = gsLevel;
+    }
+
+    public Integer getNumberPerson() {
+        return numberPerson;
+    }
+
+    public void setNumberPerson(Integer numberPerson) {
+        this.numberPerson = numberPerson;
+    }
+
+    @Override
+    public String toString() {
+        return "Worker{" +
+                "zw='" + zw + '\'' +
+                ", salary=" + salary +
+                ", address='" + address + '\'' +
+                ", workTime=" + workTime +
+                ", xl=" + xl +
+                ", gsName='" + gsName + '\'' +
+                ", gsLevel=" + gsLevel +
+                ", numberPerson=" + numberPerson +
+                '}';
+    }
+}

+ 322 - 0
src/main/java/com/sf/day14/exercisequestions/Test01.java

@@ -0,0 +1,322 @@
+package com.sf.day14.exercisequestions;
+
+import com.sf.day14.exercisequestions.model.*;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+import java.util.function.Consumer;
+import java.util.stream.Collectors;
+
+public class Test01 {
+    /**
+     * 练习题 7
+     * 7:(List)编程:创建一个工人类,属性:姓名、年龄、工资,要求如下:
+     * ①为Worker 提供无、有参数的构造方法,属性私有,并提供公开的 get/set
+     * <p>
+     * ②创建多个Worker 类,存储在List 集合中。
+     * <p>
+     * ③打印输出所有的工人信息。
+     * <p>
+     * ④计算所有工人的平均工资。
+     * <p>
+     * ⑤打印输出姓名中包含 "胡" 的所有工人信息。
+     * <p>
+     * ⑥打印输出所有姓 "胡" 的工人信息。
+     * <p>
+     * ⑦键盘输入一个姓名,查找是否存在此员工,存在,则打印输出员工的信息, 如果不存在,则输出"查 无此人"
+     * <p>
+     * ⑧输入一个工资,查询工资 大于 输入工资的员工信息。
+     */
+    @Test
+    public void t1() {
+        List<Worker> list = new ArrayList<>();
+        list.add(new Worker("张三", 18, 2000));
+        list.add(new Worker("李四", 19, 3000));
+        list.add(new Worker("王五", 20, 4000));
+        list.add(new Worker("赵胡麻", 21, 5000));
+        list.add(new Worker("胡八一", 22, 6000));
+        list.forEach(o -> System.out.println(o + " "));
+
+        System.out.println();
+        System.out.println();
+        System.out.println("---------------------------");
+
+        double average = 0;
+        for (int i = 0; i < list.size(); i++) {
+            average += list.get(i).getSalary();
+            String s = String.valueOf(list.get(i));
+            if (s.contains("胡")) {
+                System.out.println(list.get(i));
+            }
+        }
+        System.out.println();
+        System.out.println("平均工资为:" + average / 5);
+        String string = String.valueOf(list);
+        char[] chars = string.toCharArray();
+        for (int i = 0; i < chars.length; i++) {
+            if (String.valueOf(chars[i]).equals("胡")) {
+                System.out.println(chars[i]);
+            }
+        }
+
+        Scanner sc = new Scanner(System.in);
+        System.out.println("请输入名字");
+        String s1 = sc.next();
+        boolean boo = false;
+        for (int i = 0; i < list.size(); i++) {
+            if (s1.equals(list.get(i).getName())) {
+                System.out.println(list.get(i));
+                boo = true;
+            }
+        }
+        if (!boo) {
+            System.out.println("不存在");
+        }
+        System.out.println("请输入工资");
+        double d = sc.nextInt();
+        for (int i = 0; i < list.size(); i++) {
+            if (d < list.get(i).getSalary()) {
+                System.out.println(list.get(i));
+                boo = true;
+            }
+        }
+        if (!boo) {
+            System.out.println("不存在");
+        }
+    }
+
+    /**
+     * 练习题8
+     * 8:(List)编程:已知有 Worker 类,属性为姓名、年龄、工资,完成类的封装并提供无参数、有参数构造方法,完成以下要求:
+     * ①创建一个List,在List 中增加三个工人,基本信息如下 :
+     * <p>
+     * 姓名 年龄 工资
+     * <p>
+     * zhang3 18 3000
+     * <p>
+     * li4 25 3500
+     * <p>
+     * Wang5 22 3200
+     * <p>
+     * ②在li4 之前插入一个工人,信息为:姓名:zhao6,年龄:24,工资 3300
+     * <p>
+     * ③删除wang5 的信息
+     * <p>
+     * ④利用下标遍历,打印输出所有工人信息
+     * <p>
+     * ⑤利用forEach 遍历,打印输出所有年龄大于 20 的工人信息
+     * <p>
+     * ⑥对Worker 类添加eqauls 方法
+     */
+    @Test
+    public void t2() {
+        List list = new ArrayList();
+        list.add(new Worker1("zhang3", 18, 3000));
+        list.add(new Worker1("li4", 25, 3500));
+        list.add(new Worker1("wang5", 22, 3200));
+        list.add(1, new Worker1("zhao6", 24, 3300));
+        list.remove(3);
+        for (int i = 0; i < list.size(); i++) {
+            System.out.println(list.get(i));
+        }
+        System.out.println();
+        System.out.println("--------------------------");
+        for (Object w : list) {
+            Worker1 worker1 = (Worker1) w;
+            if (worker1.getAge() > 20) {
+                System.out.println(w);
+            }
+        }
+    }
+
+    /**
+     * 9:(List) 创建一个商品(Produtor)类,属性:商品名,商品单价,商品的数量,商品产地。
+     * ① 创建多个商品对象,存储在List集合中。
+     * <p>
+     * ② 显示所有的商品信息。
+     * <p>
+     * ③ 打印输出商品价格 > 1000 的所有商品信息。
+     * <p>
+     * ④ 打印售空的商品的信息。
+     * <p>
+     * ⑤ 打印输出商品产地为"北京"的商品信息。
+     * <p>
+     * ⑥ 输入一个商品名,查询出此类商品的信息,如果不存在,则打印商品"商场无此商品!!!"
+     * <p>
+     * ⑦ 输入一个价格段,查询出集合中所有在这个价格区间的所有商品信息。
+     */
+    @Test
+    public void t3() {
+        List list = new ArrayList();
+        list.add(new Produtor("小米", 4999, 99, "北京"));
+        list.add(new Produtor("红米", 999, 88, "杭州"));
+        list.add(new Produtor("华为", 6999, 0, "北京"));
+        list.add(new Produtor("苹果", 10099, 9999, "America"));
+        list.add(new Produtor("杂牌", 100, 999999, "华强北"));
+
+        list.forEach(new Consumer() {
+            @Override
+            public void accept(Object o) {
+                System.out.println(o + "");
+            }
+        });
+
+        System.out.println();
+        System.out.println("------------");
+
+        for (int i = 0; i < list.size(); i++) {
+            Produtor produtor = (Produtor) list.get(i);
+            if (produtor.getPrice() > 1000) {
+                System.out.println(produtor);
+            }
+
+        }
+        System.out.println();
+        for (int i = 0; i < list.size(); i++) {
+            Produtor produtor = (Produtor) list.get(i);
+            if (produtor.getNum() == 0) {
+                System.out.println("售空产品为:" + produtor);
+            }
+            if (produtor.getProduction().equals("北京")) {
+                System.out.println(produtor);
+            }
+
+        }
+
+        System.out.println();
+        for (int i = 0; i < list.size(); i++) {
+            Produtor produtor = (Produtor) list.get(i);
+
+            if (produtor.getProduction().equals("北京")) {
+                System.out.println(produtor);
+            }
+
+        }
+
+
+        Scanner scanner = new Scanner(System.in);
+        System.out.println("请输入商品名:");
+        String name = scanner.next();
+        boolean boo = false;
+        for (int i = 0; i < list.size(); i++) {
+            Produtor produtor = (Produtor) list.get(i);
+            if (produtor.getName().equals(name)) {
+                System.out.println(produtor);
+                boo = true;
+            }
+        }
+        if (!boo) {
+            System.out.println("不存在");
+        }
+        System.out.println("输入低价");
+
+        double price1 = scanner.nextInt();
+        System.out.println("输入高价");
+        double price2 = scanner.nextInt();
+        for (int i = 0; i < list.size(); i++) {
+            Produtor produtor = (Produtor) list.get(i);
+            if (produtor.getPrice() >= price1 && produtor.getPrice() <= price2) {
+                System.out.println(produtor);
+            }
+
+        }
+    }
+
+
+    /**
+     * 10:(List)定义一个用户类(User):---要求封装
+     * ① 属性:用户名、密码、是否在线(是-true)
+     * <p>
+     * ② 提供有参数、无参数的构造方法
+     * <p>
+     * ③ 创建多个对象,存储在集合中,并统计在线用户数量,打印在控制台上。
+     */
+    @Test
+    public void t4() {
+        List list = new ArrayList();
+        list.add(new User("张三", "123", true));
+        list.add(new User("李四", "312", false));
+        list.add(new User("王五", "456", true));
+        for (int i = 0; i < list.size(); i++) {
+            User u = (User) list.get(i);
+            if (u.isZaixian() == true) {
+                System.out.println(u);
+            }
+
+        }
+    }
+
+    /**
+     * 11:(List)定义一个员工类(Employee):---要求封装
+     * ① 属性:姓名,生日月,工资
+     * <p>
+     * ② 提供无参数\有参数的构造方法
+     * <p>
+     * ③ 创建多个员工对象,存储在Employee数组中.
+     * <p>
+     * ④ 利用toString方法展示所有员工的信息,要求格式为: 张三-10-18000.0
+     * <p>
+     * ⑤ 控制台输入当前月份,统计过生日的员工数量.
+     * <p>
+     * ⑥ 控制台输入一个工资,打印工资高于此工资的所有员工信息.
+     */
+    @Test
+    public void t5() {
+        List list = new ArrayList();
+        list.add(new Employee("张三", 10, 10000));
+        list.add(new Employee("李四", 9, 20000));
+        list.add(new Employee("王五", 8, 30000));
+        list.add(new Employee("赵六", 7, 40000));
+        Scanner sc = new Scanner(System.in);
+        System.out.println("请输入当前月份");
+        int month = sc.nextInt();
+        for (int i = 0; i < list.size(); i++) {
+            Employee e = (Employee) list.get(i);
+            if (e.getBirthday() == month) {
+                System.out.println(e);
+            }
+        }
+        System.out.println("请输入工资:");
+        double d = sc.nextInt();
+        for (int i = 0; i < list.size(); i++) {
+            Employee e = (Employee) list.get(i);
+            if (e.getSalary() > d) {
+                System.out.println(e);
+            }
+        }
+    }
+
+    /**
+     * 12:(List)在控制台输入格式为“张三/18/男/99.5”的学生若干,存于List集合中。
+     * 要求:
+     * <p>
+     * ①从数组遍历所有内容解析为学生对象,将学生在存于一个新的List集合
+     */
+    @Test
+    public void t6() {
+        Scanner scanner = new Scanner(System.in);
+        List<Student> students = new ArrayList<>();
+        boolean isRunning = true;
+        while (isRunning) {
+            System.out.print("请输入学生信息(格式:张三/18/男/99.5,输入exit结束输入):");
+            String input = scanner.nextLine();
+            if ("exit".equalsIgnoreCase(input)) {
+                isRunning = false;
+            } else {
+                String[] parts = input.split("/");
+                if (parts.length == 4) {
+                    Student student = new Student(parts[0], Integer.parseInt(parts[1]), parts[2], Double.parseDouble(parts[3]));
+                    students.add(student);
+                } else {
+                    System.out.println("输入格式不正确,请重新输入。");
+                }
+            }
+        }
+        scanner.close();
+    }
+}
+
+
+

+ 43 - 0
src/main/java/com/sf/day14/exercisequestions/model/Employee.java

@@ -0,0 +1,43 @@
+package com.sf.day14.exercisequestions.model;
+
+public class Employee {
+    private String name;
+    private int birthday;
+    private double salary;
+
+    public Employee() {
+    }
+
+    public Employee(String name, int birthday, double salary) {
+        this.name = name;
+        this.birthday = birthday;
+        this.salary = salary;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getBirthday() {
+        return birthday;
+    }
+
+    public void setBirthday(int birthday) {
+        this.birthday = birthday;
+    }
+
+    public double getSalary() {
+        return salary;
+    }
+
+    public void setSalary(double salary) {
+        this.salary = salary;
+    }
+    public String toString(){
+        return name+"-"+birthday+"-"+salary;
+    }
+}

+ 54 - 0
src/main/java/com/sf/day14/exercisequestions/model/Produtor.java

@@ -0,0 +1,54 @@
+package com.sf.day14.exercisequestions.model;
+
+public class Produtor {
+    private String name;
+    private double price;
+    private int num;
+    private String production;
+
+    public Produtor() {
+    }
+
+    public Produtor(String name, double price, int num, String production) {
+        this.name = name;
+        this.price = price;
+        this.num = num;
+        this.production = production;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public double getPrice() {
+        return price;
+    }
+
+    public void setPrice(double price) {
+        this.price = price;
+    }
+
+    public int getNum() {
+        return num;
+    }
+
+    public void setNum(int num) {
+        this.num = num;
+    }
+
+    public String getProduction() {
+        return production;
+    }
+
+    public void setProduction(String production) {
+        this.production = production;
+    }
+    public String toString(){
+        return "商品名:"+name+",价格:"+price+",数量:"+num+",产地:"+production;
+    }
+
+}

+ 57 - 0
src/main/java/com/sf/day14/exercisequestions/model/Student.java

@@ -0,0 +1,57 @@
+package com.sf.day14.exercisequestions.model;
+
+public class Student {
+    private String name;
+    private int age;
+    private String gender;
+    private Double score;
+
+    public Student(String name, int age, String gender, Double score) {
+        this.name = name;
+        this.age = age;
+        this.gender = gender;
+        this.score = score;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public String getGender() {
+        return gender;
+    }
+
+    public void setGender(String gender) {
+        this.gender = gender;
+    }
+
+    public Double getScore() {
+        return score;
+    }
+
+    public void setScore(Double score) {
+        this.score = score;
+    }
+
+    @Override
+    public String toString() {
+        return "Student{" +
+                "name='" + name + '\'' +
+                ", age=" + age +
+                ", gender='" + gender + '\'' +
+                ", score=" + score +
+                '}';
+    }
+}

+ 44 - 0
src/main/java/com/sf/day14/exercisequestions/model/User.java

@@ -0,0 +1,44 @@
+package com.sf.day14.exercisequestions.model;
+
+public class User {
+    private String name;
+    private String password;
+    private boolean zaixian;
+
+    public User() {
+    }
+
+    public User(String name, String password, boolean zaixian) {
+        this.name = name;
+        this.password = password;
+        this.zaixian = zaixian;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public boolean isZaixian() {
+        return zaixian;
+    }
+
+    public void setZaixian(boolean zaixian) {
+        this.zaixian = zaixian;
+    }
+    public String toString(){
+        return "用户名"+name+"密码"+password+"是否在线"+zaixian;
+    }
+
+}

+ 44 - 0
src/main/java/com/sf/day14/exercisequestions/model/Worker.java

@@ -0,0 +1,44 @@
+package com.sf.day14.exercisequestions.model;
+
+public class Worker {
+    private String name;
+    private int age;
+    private double salary;
+
+    public Worker() {
+    }
+
+    public Worker(String name, int age, double salary) {
+        this.name = name;
+        this.age = age;
+        this.salary = salary;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public double getSalary() {
+        return salary;
+    }
+
+    public void setSalary(double salary) {
+        this.salary = salary;
+    }
+    public String toString(){
+        return "姓名:"+name+",年龄:"+age+",薪资:"+salary;
+    }
+
+}

+ 54 - 0
src/main/java/com/sf/day14/exercisequestions/model/Worker1.java

@@ -0,0 +1,54 @@
+package com.sf.day14.exercisequestions.model;
+
+public class Worker1 {
+    private String name;
+    private int age;
+    private double salary;
+
+    public Worker1() {
+    }
+
+    public Worker1(String name, int age, double salary) {
+        this.name = name;
+        this.age = age;
+        this.salary = salary;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getAge() {
+        return age;
+    }
+
+    public void setAge(int age) {
+        this.age = age;
+    }
+
+    public double getSalary() {
+        return salary;
+    }
+
+    public void setSalary(double salary) {
+        this.salary = salary;
+    }
+
+    public String toString() {
+        return "姓名:" + name + ",年龄:" + age + ",薪资:" + salary;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (this.getClass() != o.getClass() || o.getClass() == null) {
+            return false;
+        }
+        return this.name.equals(((Worker1) o).name);
+    }
+}

+ 31 - 0
src/main/java/com/sf/ioioioioi/TTT.java

@@ -0,0 +1,31 @@
+package com.sf.ioioioioi;
+
+public class TTT {
+    static int x,y,z;
+    static {
+        int x = 5;  //m
+        x--;
+    }
+
+     static {
+        x--;
+     }
+
+    public static void method(){
+        y = z++ + ++z;  //  z = 1  //y =0
+    }
+
+
+    public static void main(String[] args) {
+        System.out.println(x);
+        z--;  //z= -1
+        method();  //y = z++ + ++z;
+        System.out.println("result+=="+(z+y+ ++z));   //最后=3   // 1+0+ 2
+    }
+
+
+    /**
+     * a = i++      a = i ;  i = i+1
+     * a= ++i       i = i+1;  a = i;
+     */
+}

+ 132 - 0
src/main/java/com/sf/ioioioioi/test01.java

@@ -0,0 +1,132 @@
+package com.sf.ioioioioi;
+
+import org.junit.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Date;
+
+public class test01 {
+    public static void main(String[] args) {
+        String pathname = "c:\\aaa.txt";
+        File file = new File(pathname);
+
+        // 文件路径名
+        String pathname2 = "D:\\aaa\\bbb.txt";
+        File file2 = new File(pathname2);
+
+        // 通过父路径和子路径字符串
+        String parent = "d:\\aaa";
+        String child = "bbb.txt";
+        File file3 = new File(parent, child);
+
+        // 通过父级File对象和子路径字符串
+        File parentDir = new File("d:\\aaa");
+        String childFile = "bbb.txt";
+        File file4 = new File(parentDir, childFile);
+    }
+
+    @Test
+    public void t2(){
+        File f1 = new File("d:\\a.txt");
+        System.out.println("文件/目录的名称:" + f1.getName());
+        System.out.println("文件/目录的构造路径名:" + f1.getPath());
+        System.out.println("文件/目录的绝对路径名:" + f1.getAbsolutePath());
+        System.out.println("文件/目录的父目录名:" + f1.getParent());
+    }
+
+    @Test
+    public void t3(){
+        File f3 = new File("a.txt");
+        System.out.println("user.dir =" + System.getProperty("user.dir"));
+        System.out.println("文件/目录的名称:" + f3.getName());
+        System.out.println("文件/目录的构造路径名:" + f3.getPath());
+        System.out.println("文件/目录的绝对路径名:" + f3.getAbsolutePath());
+        System.out.println("文件/目录的父目录名:" + f3.getParent());
+    }
+
+    @Test
+    public void t4(){
+        File f = new File("d:/aaa/bbb.txt");
+        System.out.println("文件构造路径:"+f.getPath());
+        System.out.println("文件名称:"+f.getName());
+        System.out.println("文件长度:"+f.length()+"字节");
+        System.out.println("文件最后修改时间:" + f.lastModified());
+
+        File f2 = new File("d:/aaa");
+        System.out.println("目录构造路径:"+f2.getPath());
+        System.out.println("目录名称:"+f2.getName());
+        System.out.println("目录长度:"+f2.length()+"字节");
+        System.out.println("文件最后修改时间:" + new Date(f.lastModified()));
+    }
+
+    @Test
+    public void t5(){
+        File dir = new File("d:/ruanjian");
+        String[] subs = dir.list();
+        System.out.println(Arrays.toString(subs));
+        for (String sub : subs) {
+            System.out.println(sub);
+        }
+    }
+
+    @Test
+    public void t6(){
+        File file1 = new File("d:/a.txt");
+        File file2 = new File("d:/b.txt");
+        System.out.println(file1.getName());
+        boolean b = file1.renameTo(file2);
+        System.out.println(b);
+    }
+
+    @Test
+    public void t7(){
+        File f = new File("d:\\a.txt");
+        File f2 = new File("d:\\tmp");
+        // 判断是否存在
+        System.out.println("d:\\aaa\\bbb.java 是否存在:"+f.exists());
+        System.out.println("d:\\aaa 是否存在:"+f2.exists());
+        // 判断是文件还是目录
+        System.out.println("d:\\aaa 文件?:"+f2.isFile());
+        System.out.println("d:\\aaa 目录?:"+f2.isDirectory());
+    }
+
+    @Test
+    public void t8() throws IOException {
+        // 文件的创建
+        File f = new File("aaa.txt");
+        System.out.println("aaa.txt是否存在:"+f.exists());
+        System.out.println("aaa.txt是否创建:"+f.createNewFile());
+        System.out.println("aaa.txt是否存在:"+f.exists());
+
+        // 目录的创建
+        File f2= new File("newDir");
+        System.out.println("newDir是否存在:"+f2.exists());
+        System.out.println("newDir是否创建:"+f2.mkdir());
+        System.out.println("newDir是否存在:"+f2.exists());
+
+        // 创建一级目录
+        File f3= new File("newDira\\newDirb");
+        System.out.println("newDira\\newDirb创建:" + f3.mkdir());
+        File f4= new File("newDir\\newDirb");
+        System.out.println("newDir\\newDirb创建:" + f4.mkdir());
+        // 创建多级目录
+        File f5= new File("newDira\\newDirb");
+        System.out.println("newDira\\newDirb创建:" + f5.mkdirs());
+
+        // 文件的删除
+        System.out.println("aaa.txt删除:" + f.delete());
+
+        // 目录的删除
+        System.out.println("newDir删除:" + f2.delete());
+        System.out.println("newDir\\newDirb删除:" + f4.delete());
+    }
+
+    @Test
+    public void t9(){
+
+    }
+
+}
+

BIN
target/classes/com/sf/day13/System/Test.class


BIN
target/classes/com/sf/day14/Person.class


BIN
target/classes/com/sf/day14/Test01$1.class


BIN
target/classes/com/sf/day14/Test01.class


BIN
target/classes/com/sf/day14/Worker.class


BIN
target/classes/com/sf/day14/exercisequestions/Test01.class


BIN
target/classes/com/sf/day14/exercisequestions/Worker.class


BIN
target/classes/com/sf/day14/exercisequestions/Worker1.class


BIN
target/classes/com/sf/ioioioioi/TTT.class


BIN
target/classes/com/sf/ioioioioi/test01.class