Khalil Saboor 6 years ago
parent
commit
fb131923c8
6 changed files with 40 additions and 28 deletions
  1. 2
    2
      Cat.java
  2. 1
    7
      Dog.java
  3. 2
    3
      Frog.java
  4. 2
    2
      MainApplication.java
  5. 0
    1
      Pet.java
  6. 33
    13
      package.bluej

+ 2
- 2
Cat.java View File

8
 public class Cat extends Pet
8
 public class Cat extends Pet
9
 {
9
 {
10
     public Cat (String name){    
10
     public Cat (String name){    
11
-        super(name);       
11
+        super(name);    
12
+        super.setType("");
12
     }
13
     }
13
     
14
     
14
     public String speak(){    
15
     public String speak(){    
15
         return "mewo";
16
         return "mewo";
16
     }
17
     }
17
-    
18
 }
18
 }

+ 1
- 7
Dog.java View File

9
 {
9
 {
10
     public Dog (String name){
10
     public Dog (String name){
11
         super(name);
11
         super(name);
12
-        super.setType("h");
12
+        super.setType("");
13
     }
13
     }
14
     public String speak(){
14
     public String speak(){
15
 
15
 
16
         return "Bark!";
16
         return "Bark!";
17
     }  
17
     }  
18
-    public String getName(){
19
-    
20
-        return "Max";
21
-    
22
-    }
23
-    
24
 }
18
 }

+ 2
- 3
Frog.java View File

7
  */
7
  */
8
 public class Frog extends Pet
8
 public class Frog extends Pet
9
 {
9
 {
10
-   public Frog (String name){
11
-    
10
+   public Frog (String name){    
12
         super(name);
11
         super(name);
12
+        super.setType("");
13
     }
13
     }
14
-    
15
    public String speak(){
14
    public String speak(){
16
     
15
     
17
         return "ribbit";
16
         return "ribbit";

+ 2
- 2
MainApplication.java View File

4
 */
4
 */
5
 public class MainApplication {
5
 public class MainApplication {
6
 
6
 
7
- enum petTypes{CAT, DOG, SNAKE, DEFAULT};
7
+ enum petTypes{CAT, DOG, FROG, DEFAULT};
8
  public static void main(String[]args){
8
  public static void main(String[]args){
9
 
9
 
10
      Scanner scan = new Scanner(System.in);
10
      Scanner scan = new Scanner(System.in);
30
              petArr[i] = new Dog(typeName);
30
              petArr[i] = new Dog(typeName);
31
              break;
31
              break;
32
 
32
 
33
-             case SNAKE:
33
+             case FROG:
34
              petArr[i] = new Frog(typeName);
34
              petArr[i] = new Frog(typeName);
35
              break;
35
              break;
36
            
36
            

+ 0
- 1
Pet.java View File

8
 public class Pet 
8
 public class Pet 
9
 {
9
 {
10
     private String name;
10
     private String name;
11
-    
12
     private String type;
11
     private String type;
13
     public Pet (String name){
12
     public Pet (String name){
14
         this.name = name;
13
         this.name = name;

+ 33
- 13
package.bluej View File

1
 #BlueJ package file
1
 #BlueJ package file
2
+dependency1.from=MainApplication
3
+dependency1.to=Pet
4
+dependency1.type=UsesDependency
5
+dependency2.from=MainApplication
6
+dependency2.to=Cat
7
+dependency2.type=UsesDependency
8
+dependency3.from=MainApplication
9
+dependency3.to=Dog
10
+dependency3.type=UsesDependency
11
+dependency4.from=MainApplication
12
+dependency4.to=Frog
13
+dependency4.type=UsesDependency
2
 editor.fx.0.height=722
14
 editor.fx.0.height=722
3
 editor.fx.0.width=947
15
 editor.fx.0.width=947
4
 editor.fx.0.x=333
16
 editor.fx.0.x=333
13
 package.editor.y=59
25
 package.editor.y=59
14
 package.frame.height=600
26
 package.frame.height=600
15
 package.frame.width=800
27
 package.frame.width=800
16
-package.numDependencies=0
17
-package.numTargets=6
28
+package.numDependencies=4
29
+package.numTargets=7
18
 package.showExtends=true
30
 package.showExtends=true
19
 package.showUses=true
31
 package.showUses=true
20
 project.charset=UTF-8
32
 project.charset=UTF-8
45
 target3.x=300
57
 target3.x=300
46
 target3.y=300
58
 target3.y=300
47
 target4.height=50
59
 target4.height=50
48
-target4.name=Dog
60
+target4.name=PetTest
49
 target4.showInterface=false
61
 target4.showInterface=false
50
-target4.type=ClassTarget
62
+target4.type=UnitTestTargetJunit4
51
 target4.width=80
63
 target4.width=80
52
-target4.x=470
53
-target4.y=230
64
+target4.x=340
65
+target4.y=120
54
 target5.height=50
66
 target5.height=50
55
-target5.name=Pet
67
+target5.name=Dog
56
 target5.showInterface=false
68
 target5.showInterface=false
57
 target5.type=ClassTarget
69
 target5.type=ClassTarget
58
 target5.width=80
70
 target5.width=80
59
-target5.x=310
60
-target5.y=150
71
+target5.x=470
72
+target5.y=230
73
+target6.association=PetTest
61
 target6.height=50
74
 target6.height=50
62
-target6.name=MainApplication
75
+target6.name=Pet
63
 target6.showInterface=false
76
 target6.showInterface=false
64
 target6.type=ClassTarget
77
 target6.type=ClassTarget
65
-target6.width=120
66
-target6.x=70
67
-target6.y=70
78
+target6.width=80
79
+target6.x=310
80
+target6.y=150
81
+target7.height=50
82
+target7.name=MainApplication
83
+target7.showInterface=false
84
+target7.type=ClassTarget
85
+target7.width=120
86
+target7.x=70
87
+target7.y=70