Browse Source

王烊烊202302050115W6

master
WangYangyang 6 days ago
parent
commit
a3eb86f50d
  1. 2
      Encapsulation_Inheritance_Polymorphism/pom.xml
  2. 0
      Encapsulation_Inheritance_Polymorphism/src/main/java/org/example/App.java
  3. 0
      Encapsulation_Inheritance_Polymorphism/src/test/java/org/example/AppTest.java
  4. 25
      MyPic/pom.xml
  5. 13
      MyPic/src/main/java/org/example/App.java
  6. 38
      MyPic/src/test/java/org/example/AppTest.java
  7. 25
      interface/pom.xml
  8. 13
      interface/src/main/java/org/example/App.java
  9. 38
      interface/src/test/java/org/example/AppTest.java
  10. 25
      w6/pom.xml
  11. 5
      w6/src/main/java/com/w6/Animal.java
  12. 8
      w6/src/main/java/com/w6/Cat.java
  13. 11
      w6/src/main/java/com/w6/Dog.java
  14. 18
      w6/src/main/java/com/w6/Main.java
  15. 5
      w6/src/main/java/com/w6/Swimmable.java
  16. 13
      w6/src/main/java/org/example/App.java
  17. 38
      w6/src/test/java/org/example/AppTest.java
  18. BIN
      w6/target/classes/com/w5/Animal.class
  19. BIN
      w6/target/classes/com/w5/Cat.class
  20. BIN
      w6/target/classes/com/w5/Dog.class
  21. BIN
      w6/target/classes/com/w5/Main.class
  22. BIN
      w6/target/classes/com/w5/Swimmable.class
  23. BIN
      w6/target/classes/org/example/App.class
  24. 25
      实验一CarProject/pom.xml
  25. 13
      实验一CarProject/src/main/java/org/example/App.java
  26. 38
      实验一CarProject/src/test/java/org/example/AppTest.java

2
封装继承多态/pom.xml → Encapsulation_Inheritance_Polymorphism/pom.xml

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId> <groupId>org.example</groupId>
<artifactId>封装继承多态</artifactId> <artifactId>Encapsulation_Inheritance_Polymorphism</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>

0
封装继承多态/src/main/java/org/example/App.java → Encapsulation_Inheritance_Polymorphism/src/main/java/org/example/App.java

0
封装继承多态/src/test/java/org/example/AppTest.java → Encapsulation_Inheritance_Polymorphism/src/test/java/org/example/AppTest.java

25
MyPic/pom.xml

@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>MyPic</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>project2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

13
MyPic/src/main/java/org/example/App.java

@ -0,0 +1,13 @@
package org.example;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

38
MyPic/src/test/java/org/example/AppTest.java

@ -0,0 +1,38 @@
package org.example;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

25
interface/pom.xml

@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>interface</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>interface</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

13
interface/src/main/java/org/example/App.java

@ -0,0 +1,13 @@
package org.example;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

38
interface/src/test/java/org/example/AppTest.java

@ -0,0 +1,38 @@
package org.example;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

25
w6/pom.xml

@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>w6</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>w6</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

5
w6/src/main/java/com/w6/Animal.java

@ -0,0 +1,5 @@
package com.w6;
public abstract class Animal {
abstract void makeSound();
}

8
w6/src/main/java/com/w6/Cat.java

@ -0,0 +1,8 @@
package com.w6;
public class Cat extends Animal{
@Override
public void makeSound(){
System.out.println("喵喵喵");
}
}

11
w6/src/main/java/com/w6/Dog.java

@ -0,0 +1,11 @@
package com.w6;
public class Dog extends Animal implements Swimmable{
@Override
public void makeSound() {
System.out.println("汪汪汪");
}
public void swim(){
System.out.println("狗会游泳");
}
}

18
w6/src/main/java/com/w6/Main.java

@ -0,0 +1,18 @@
package com.w6;
public class Main {
public static void main (String []args){
Animal[] animals=new Animal[2];
animals[0]=new Dog();
animals[1]=new Cat();
for(Animal a: animals){
a.makeSound();
if(a instanceof Swimmable){
((Swimmable)a).swim();
}
else{
System.out.println("该动物不能游泳");
}
}
}
}

5
w6/src/main/java/com/w6/Swimmable.java

@ -0,0 +1,5 @@
package com.w6;
public interface Swimmable {
void swim();
}

13
w6/src/main/java/org/example/App.java

@ -0,0 +1,13 @@
package org.example;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

38
w6/src/test/java/org/example/AppTest.java

@ -0,0 +1,38 @@
package org.example;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

BIN
w6/target/classes/com/w5/Animal.class

Binary file not shown.

BIN
w6/target/classes/com/w5/Cat.class

Binary file not shown.

BIN
w6/target/classes/com/w5/Dog.class

Binary file not shown.

BIN
w6/target/classes/com/w5/Main.class

Binary file not shown.

BIN
w6/target/classes/com/w5/Swimmable.class

Binary file not shown.

BIN
w6/target/classes/org/example/App.class

Binary file not shown.

25
实验一CarProject/pom.xml

@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>实验一CarProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>CarProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

13
实验一CarProject/src/main/java/org/example/App.java

@ -0,0 +1,13 @@
package org.example;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

38
实验一CarProject/src/test/java/org/example/AppTest.java

@ -0,0 +1,38 @@
package org.example;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
Loading…
Cancel
Save