diff --git "a/22 \345\274\240\351\276\231\350\205\276/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/2022.12.27\351\235\242\345\220\221\345\257\271\350\261\241\347\254\224\350\256\260.md" "b/22 \345\274\240\351\276\231\350\205\276/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/2022.12.27\351\235\242\345\220\221\345\257\271\350\261\241\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..f57a32779d7bff5f2aea8080d54c4bea1c261f78 --- /dev/null +++ "b/22 \345\274\240\351\276\231\350\205\276/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/2022.12.27\351\235\242\345\220\221\345\257\271\350\261\241\347\254\224\350\256\260.md" @@ -0,0 +1,78 @@ +# 笔记 + +## 什么是类? + +#### 类是对现实生活一类具有共同属性和行为的事物的抽象,确认对象将会拥有的属性和行为 + +类是抽象的对象 + +可以理解成设计图,还不是真实存在的 + +## 什么是对象? + +对象是类的实体 + +可以理解为看得见、摸得着的东西,从设计图设计出来的实物等 + +## 对象的属性和行为 + +#### 属性【(在类中通过成员变量来体现)类中方法外的变量】 + +对象具有的各种特征,每个对象的每个属性都拥有特定的值 + +属性 值 + +品牌: 小米 + +价格: 2999 + +内存: 128G + +#### 行为 【(在类中通过成员方法来体现)和前面的方法相比去掉static关键词即可】 + +对象能够执行的操作 + +手机 打电话 看视频等 + +## 实例 + +如 + +### 成员变量(属性) + +String band 品牌 + +double price 价格 + +String color 颜色 + +### 成员方法(行为) + +sout("我能打电话") + +sout("我能打游戏") + + + +## 对象的使用 + +创建对象 + +格式:类名 对象名=new 类名(); + +例子:phone p =ne phone(); + +## 使用对象 + +1.使用成员变量 + +格式:对象名,变量名 + +例子:p:brand + +2.使用成员方法 + +格式:对象名,方法名(参数) + +例子:p,call() + diff --git "a/22 \345\274\240\351\276\231\350\205\276/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/2022.12.23.md" "b/22 \345\274\240\351\276\231\350\205\276/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/2022.12.23.md" new file mode 100644 index 0000000000000000000000000000000000000000..e1cc9ba6abe3d0f217959e739debc92c99dbec41 --- /dev/null +++ "b/22 \345\274\240\351\276\231\350\205\276/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/2022.12.23.md" @@ -0,0 +1,159 @@ +```java +import java.util.Scanner; + +public class guanlixitong { + static Scanner sc = new Scanner(System.in); + static String[] stu = new String[66]; + public static void main(String[] args) { + stu[0] = "菜需捆"; + stu[1] = "卢本伟"; + stu[2] = "社会你虎哥"; + stu[3] = "忧郁蓝调汤姆"; + stu[4] = ""; + + aa: while (true){ + Welcome(); + int a = choice(sc.nextInt()); + if (a==1){ + break ;//中止while + } + } + + } + //欢迎界面 +// 搜索学生 + public static void Allstudent() { + System.out.println("只因班学生如下:"); + int count =0; + for (String name : stu) { + if (name==null){ + count++; + continue; + } + System.out.println(name + "\t"); + } + if (count== stu.length){ + System.out.println("目前还没有该学生信息"); + } + } + public static void Welcome() { + System.out.println( + "\n============================" + + "\n- 欢迎使用3班学生管理系统 --" + + "\n- 1.浏览所有学生信息 -" + + "\n- 2.添加学生信息 -" + + "\n- 3.修改学生信息 -" + + "\n- 4.删除学生信息 -" + + "\n- 5.查询学生信息 -" + + "\n- 6.退出管理系统 -" + + "\n =========================" + + "\n请输入对应的数字选择你需要的功能:"); + } + //这个是菜单 + public static int choice(int num){ + int a =0; + switch (num) { + case 1: + //浏览 + Allstudent(); + break; + case 2: + //添加 + addstudent(); + break; + case 3: + //修改 + editStudent(); + break; + case 4: + //删除 + deleteStudent(); + break; + case 5: + //查询 + searchStudent(); + break; + case 6: + //结束 + System.out.println("你选择了退出系统"); + + default: + System.out.println("你故意找茬是吧?"); + a=1; + } + return a; + } +// 这个是添加学生 +public static void addstudent() { + System.out.println("请输入你要添加的学生"); + String name = sc.next(); + int index = search( name); + if (index != -1) { + System.out.println("该学生已经在数据库了,请不要重复添加"); + } else { + int nullIndex = search(null); + stu[nullIndex] = name; + System.out.println("添加成功"); + Allstudent(); + + } +} +// 这个是修改学生 +private static void editStudent(){ + System.out.println("请问你要修改那个学生"); + String name =sc.next(); + int index =search(name); + if (index==-1){ + System.out.println("对不起,没有该学生,无法修改"); + }else { + System.out.println("请问你要把【"+name+"】修改为谁:"); + String newNmae = sc.next(); + stu[index]= newNmae; + System.out.println("修改成功!"); + } +} +// 这个是删除学生 +private static void deleteStudent() { + System.out.println("请问你要删除哪个学生"); + String name= sc.next(); + int index =search(name); + if (index==-1){ + System.out.println("对不起,没有该学生,无法删除"); + }else { + stu[index]=null; + System.out.println("删除成功"); + } +} +// 这个是查询学生 +public static void searchStudent(){ + System.out.println("请输入要查找的学生姓名"); + String name =sc.next(); + int index =search(name); + if (index==-1){ + System.out.println("对不起,没有该学生"); + }else { + System.out.println("找到了,Ta在第"+(index+1)+"个"); + } +} + public static int search( String str) { + int index = -1; + if (str == null) { + for (int i = 0; i < stu.length; i++) { + if (stu[i]==null){ + index = i; + break; + } + } + }else { + for (int i = 0; i < stu.length; i++) { + if (str.equals(stu[i])) { + index=i; + return index; + } + } + } + return index; + } + +} +``` \ No newline at end of file