From c540dbbbc59c81cb1c83b818de0b58875389e3b9 Mon Sep 17 00:00:00 2001 From: pj9x8ikrt <1815214374@qq.com> Date: Wed, 13 Dec 2023 18:56:32 +0800 Subject: [PATCH] ADD file via upload --- 新建文本文档.txt | 325 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 325 insertions(+) create mode 100644 新建文本文档.txt diff --git a/新建文本文档.txt b/新建文本文档.txt new file mode 100644 index 0000000..f23142a --- /dev/null +++ b/新建文本文档.txt @@ -0,0 +1,325 @@ +Ïß³Ì + +package step1; +//ÇëÔÚ´ËÌí¼ÓʵÏÖ´úÂë +/********** Begin **********/ +public class ThreadClassOne extends Thread{ + public int i=0; + public ThreadClassOne(){ + super(); + } + public void run(){ + for(i=0;i<10;i++){ + if(i%2==1) + System.out.print(i+" "); + } + } +} +/********** End **********/ + + +package step3; + +import java.util.Scanner; + +public class HelloStep3 { + public static void main(String[] args) { + System.out.println("ÐǼ¶³É¼¨ÆÀ¶¨ÏµÍ³"); + System.out.println("ÇëÊäÈë³É¼¨£º"); + Scanner sc = new Scanner(System.in); + /******start******/ + int scope = sc.nextInt(); + if(scope >=90) { + System.out.print("*****ÎåÐdzɼ¨"); + } else if(scope>=80 && scope<90) { + System.out.print("****ËÄÐdzɼ¨"); + } else if(scope>=70 && scope<80) { + System.out.print("***ÈýÐdzɼ¨"); + } else if(scope>=60 && scope<70) { + System.out.print("**Á©Ðdzɼ¨"); + } else { + System.out.print("ÎÞÐdzɼ¨"); + } + + + + + + + /******end******/ + } +} + + + + + +package step4; + +import java.util.Scanner; + +public class HelloSwitch { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("ÇëÊäÈëÔ·ݣº"); + + int input = sc.nextInt(); //»ñÈ¡ÊäÈëµÄÔÂ·Ý + + //ͨ¹ýÊäÈëµÄÔ·ÝÀ´Åжϵ±Ç°¼¾½Ú²¢Êä³ö + /*****start*****/ + + +switch (input) { +case 1: +System.out.println(input+"ÔÂÊǶ¬Ìì"); +break; +case 2: +System.out.println(input+"ÔÂÊǶ¬Ìì"); +break; +case 3: +System.out.println(input+"ÔÂÊÇ´ºÌì"); +break; +case 4: +System.out.println(input+"ÔÂÊÇ´ºÌì"); +break; +case 5: +System.out.println(input+"ÔÂÊÇ´ºÌì"); +break; +case 6: +System.out.println(input+"ÔÂÊÇÏÄÌì"); +break; +case 7: +System.out.println(input+"ÔÂÊÇÏÄÌì"); +break; +case 8: +System.out.println(input+"ÔÂÊÇÏÄÌì"); +break; +case 9: +System.out.println(input+"ÔÂÊÇÇïÌì"); +break; +case 10: +System.out.println(input+"ÔÂÊÇÇïÌì"); +break; +case 11: +System.out.println(input+"ÔÂÊÇÇïÌì"); +break; +case 12: +System.out.println(input+"ÔÂÊǶ¬Ìì"); +break; + + +} + + /*****end*****/ + + } +} + +package step3; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; + +public class Task { + + public void task() throws IOException{ + /********* Begin *********/ + String file1 = "src/step3/input/input.txt"; + FileReader fr = new FileReader(file1); + char[] cbuf = new char[8]; + fr.read(cbuf); + String file2 = "src/step3/output/output.txt"; + FileWriter fw = new FileWriter(file2); + fw.write(cbuf); + fr.close(); + fw.flush(); + fw.close(); + /********* End *********/ + } +} + + + +package step4; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; + +public class Task { + + public void task() throws IOException{ + /********* Begin *********/ + FileReader fr = new FileReader("src/step4/input/input.txt"); + FileWriter fw = new FileWriter("src/step4/output/output.txt"); + int len = 0; + char[] cbuf = new char[1024]; + while ((len = fr.read(cbuf))!=-1) + { + fw.write(cbuf,0,len); + } + fr.close(); + fw.flush(); + fw.close(); + + FileInputStream fs = new FileInputStream("src/step4/input/input.jpg"); + FileOutputStream fos = new FileOutputStream("src/step4/output/output.jpg"); + int le = 0; + byte[] bt = new byte[1024]; + while ((le = fs.read(bt))!=-1) + { + fos.write (bt,0,le); + } + fs.close(); + fos.flush(); + fos.close(); + /********* End *********/ + } +} + + + +package case1; + +public class TestPersonDemo { + public static void main(String[] args) { + /********* begin *********/ + // ÉùÃ÷²¢ÊµÀý»¯Ò»Person¶ÔÏóp + Person p = new Person(); + // ¸øpÖеÄÊôÐÔ¸³Öµ + p.setName("ÕÅÈý"); + p.setAge(18); + // µ÷ÓÃPersonÀàÖеÄtalk()·½·¨ + p.talk(); + /********* end *********/ + + } +} + +// ÔÚÕâÀﶨÒåPersonÀà +class Person { + /********* begin *********/ + + private String name; + private int age; + public String getNmae(){ + return name; + } + public void setName(String name){ + this.name = name; + } + public int getAge(){ + return age; + } + public void setAge(int age){ + this.age = age; + } + public void talk(){ + System.out.println("ÎÒÊÇ£º"+name+"£¬½ñÄ꣺"+age+"Ëê"); + } + /********* end *********/ +} + + +package case2; + +public class extendsTest { + public static void main(String args[]) { + // ʵÀý»¯Ò»¸öCat¶ÔÏó£¬ÉèÖÃÊôÐÔnameºÍage£¬µ÷ÓÃvoice()ºÍeat()·½·¨£¬ÔÙ´òÓ¡³öÃû×ÖºÍÄêÁäÐÅÏ¢ + /********* begin *********/ + Cat cat = new Cat(); + cat.name = "´ó»¨Ã¨"; + cat.age = "6Ëê"; + cat.voice(); + cat.eat(); + System.out.println(cat.name+cat.age); + /********* end *********/ + + // ʵÀý»¯Ò»¸öDog¶ÔÏó£¬ÉèÖÃÊôÐÔnameºÍage£¬µ÷ÓÃvoice()ºÍeat()·½·¨£¬ÔÙ´òÓ¡³öÃû×ÖºÍÄêÁäÐÅÏ¢ + /********* begin *********/ + Dog dog = new Dog(); + dog.name = "´óºÚ¹·"; + dog.age = "8Ëê"; + dog.voice(); + dog.eat(); + System.out.println(dog.name+dog.age); + + /********* end *********/ + + } +} + +class Animal { + /********* begin *********/ + String name; + String age; + /********* end *********/ + +} + +class Cat extends Animal { + // ¶¨ÒåCatÀàµÄvoice()ºÍeat()·½·¨ + /********* begin *********/ + + public void voice(){ + System.out.println(name+"ß÷ß÷½Ð"); + } + public void eat(){ + System.out.println(name+"³ÔÓã"); + } + /********* end *********/ +} + +class Dog extends Animal { + // ¶¨ÒåDogÀàµÄvoice()ºÍeat()·½·¨ + /********* begin *********/ + public void voice(){ + System.out.println(name+"ÍôÍô½Ð"); + } + public void eat(){ + System.out.println(name+"³Ô¹ÇÍ·"); + } + /********* end *********/ +} + + +package case7; + +public class interfaceTest { + public static void main(String[] args) { + // ʵÀý»¯Ò»StudentµÄ¶ÔÏós£¬²¢µ÷ÓÃtalk()·½·¨£¬´òÓ¡ÐÅÏ¢ + /********* begin *********/ + Student s = new Student(); + s.talk(); + /********* end *********/ + + } +} + +// ÉùÃ÷Ò»¸öPerson½Ó¿Ú£¬²¢ÔÚÀïÃæÉùÃ÷Èý¸ö³£Á¿£ºname¡¢ageºÍoccupation£¬²¢·Ö±ð¸³Öµ£¬ÉùÃ÷Ò»³éÏó·½·¨talk() +interface Person { + /********* begin *********/ + String name = "ÕÅÈý"; + int age = 18; + String occupation = "ѧÉú"; + public abstract void talk(); + + /********* end *********/ +} + +// StudentÀà¼Ì³Ð×ÔPersonÀà ¸´Ð´talk()·½·¨·µ»ØÐÕÃû¡¢ÄêÁäºÍÖ°ÒµÐÅÏ¢ +class Student implements Person { + + + /********* begin *********/ + public void talk() { + System.out.println("ѧÉú¡ª¡ª>ÐÕÃû£º"+name+"£¬ÄêÁ䣺"+age+"£¬Ö°Òµ£º"+occupation+"£¡"); + } + /********* end *********/ +}