Ben Blinebury пре 6 година
родитељ
комит
2ebe2ed2ef
7 измењених фајлова са 197 додато и 8 уклоњено
  1. 20
    0
      Bird.java
  2. 21
    0
      Cat.java
  3. 2
    2
      CatTest.java
  4. 20
    0
      Dog.java
  5. 31
    0
      MainApplication.java
  6. 24
    0
      Pet.java
  7. 79
    6
      package.bluej

+ 20
- 0
Bird.java Прегледај датотеку

@@ -0,0 +1,20 @@
1
+
2
+/**
3
+ * Write a description of class Bird here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class Bird extends Pet
9
+{
10
+    String name;
11
+    
12
+    public Bird (String name) {
13
+        super(name);
14
+    }
15
+    
16
+    @Override
17
+    public String speak() {
18
+        return "poo-tee-weet";
19
+    }
20
+}

+ 21
- 0
Cat.java Прегледај датотеку

@@ -0,0 +1,21 @@
1
+
2
+/**
3
+ * Write a description of class Cat here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class Cat extends Pet
9
+{
10
+    String name;
11
+    
12
+    public Cat (String name) {
13
+        super(name);
14
+    }
15
+    
16
+    @Override
17
+    public String speak() {
18
+        return "meow";
19
+    }
20
+}
21
+

+ 2
- 2
CatTest.java Прегледај датотеку

@@ -1,6 +1,6 @@
1 1
 
2 2
 
3
-import static org.junit.Assert.*;
3
+import org.junit.Assert;
4 4
 import org.junit.After;
5 5
 import org.junit.Before;
6 6
 import org.junit.Test;
@@ -34,7 +34,7 @@ public class CatTest
34 34
     @Test
35 35
     public void getName() {
36 36
         String expected = "Sassy";
37
-        String actual = iago.getName();
37
+        String actual = sassy.getName();
38 38
         
39 39
         Assert.assertEquals(expected, actual);
40 40
     }

+ 20
- 0
Dog.java Прегледај датотеку

@@ -0,0 +1,20 @@
1
+
2
+/**
3
+ * Write a description of class Dog here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class Dog extends Pet
9
+{
10
+    String name;
11
+    
12
+    public Dog (String name) {
13
+        super(name);
14
+    }
15
+    
16
+    @Override
17
+    public String speak() {
18
+        return "woof";
19
+    }
20
+}

+ 31
- 0
MainApplication.java Прегледај датотеку

@@ -1,5 +1,36 @@
1
+import java.util.*;
2
+
1 3
 /**
2 4
  * Created by leon on 11/6/17.
3 5
  */
4 6
 public class MainApplication {
7
+    public static void main(String[] args) {
8
+        
9
+    }
10
+    
11
+    public int getPetNumber() {
12
+        Scanner scan = new Scanner(System.in);
13
+        System.out.println("How many pets do you have?");
14
+        int petNumber = scan.nextInt();
15
+        return petNumber;
16
+    }
17
+    
18
+    public String setNames(int petNumber) {
19
+        Scanner scan  = new Scanner(System.in);
20
+        
21
+        int p = 0;
22
+        String [] name = new String [petNumber];
23
+        String namePet = scan.nextLine();
24
+        
25
+        while (p < petNumber) {
26
+                System.out.println("What kind of pet is #"  + (p+1));
27
+                String typePet = scan.nextLine();
28
+                name[p] += typePet;
29
+                System.out.println("What is the " + typePet  + "'s name?");
30
+                String petName = scan.nextLine();
31
+                name[p+1] += petName;
32
+                p++;
33
+        }
34
+        return null;
35
+    }
5 36
 }

+ 24
- 0
Pet.java Прегледај датотеку

@@ -0,0 +1,24 @@
1
+
2
+/**
3
+ * Write a description of class Pet here.
4
+ *
5
+ * @author (your name)
6
+ * @version (a version number or a date)
7
+ */
8
+public class Pet
9
+{
10
+    String name = "";
11
+    
12
+    public Pet (String name) {
13
+        this.name = name;
14
+    }
15
+    
16
+    public String getName() {
17
+        return name;
18
+    }
19
+    
20
+    public String speak() {
21
+        return "noise";
22
+    }
23
+    
24
+}

+ 79
- 6
package.bluej Прегледај датотеку

@@ -1,20 +1,23 @@
1 1
 #BlueJ package file
2
+dependency1.from=CatTest
3
+dependency1.to=Cat
4
+dependency1.type=UsesDependency
2 5
 editor.fx.0.height=722
3 6
 editor.fx.0.width=800
4
-editor.fx.0.x=560
5
-editor.fx.0.y=117
7
+editor.fx.0.x=3
8
+editor.fx.0.y=66
6 9
 objectbench.height=101
7 10
 objectbench.width=461
8 11
 package.divider.horizontal=0.6
9 12
 package.divider.vertical=0.8007380073800738
10 13
 package.editor.height=427
11 14
 package.editor.width=674
12
-package.editor.x=141
13
-package.editor.y=59
15
+package.editor.x=28
16
+package.editor.y=173
14 17
 package.frame.height=600
15 18
 package.frame.width=800
16
-package.numDependencies=0
17
-package.numTargets=0
19
+package.numDependencies=1
20
+package.numTargets=10
18 21
 package.showExtends=true
19 22
 package.showUses=true
20 23
 project.charset=UTF-8
@@ -23,3 +26,73 @@ readme.name=@README
23 26
 readme.width=47
24 27
 readme.x=10
25 28
 readme.y=10
29
+target1.height=50
30
+target1.name=MainApplicationTest
31
+target1.showInterface=false
32
+target1.type=ClassTarget
33
+target1.width=150
34
+target1.x=130
35
+target1.y=10
36
+target10.height=50
37
+target10.name=MainApplication
38
+target10.showInterface=false
39
+target10.type=ClassTarget
40
+target10.width=120
41
+target10.x=70
42
+target10.y=70
43
+target2.height=50
44
+target2.name=BirdTest
45
+target2.showInterface=false
46
+target2.type=UnitTestTargetJunit4
47
+target2.width=80
48
+target2.x=150
49
+target2.y=280
50
+target3.height=50
51
+target3.name=Bird
52
+target3.showInterface=false
53
+target3.type=ClassTarget
54
+target3.width=80
55
+target3.x=170
56
+target3.y=300
57
+target4.height=50
58
+target4.name=PetTest
59
+target4.showInterface=false
60
+target4.type=UnitTestTargetJunit4
61
+target4.width=80
62
+target4.x=350
63
+target4.y=70
64
+target5.height=50
65
+target5.name=Cat
66
+target5.showInterface=false
67
+target5.type=ClassTarget
68
+target5.width=80
69
+target5.x=310
70
+target5.y=320
71
+target6.height=50
72
+target6.name=CatTest
73
+target6.showInterface=false
74
+target6.type=UnitTestTargetJunit4
75
+target6.width=80
76
+target6.x=290
77
+target6.y=300
78
+target7.height=50
79
+target7.name=DogTest
80
+target7.showInterface=false
81
+target7.type=UnitTestTargetJunit4
82
+target7.width=80
83
+target7.x=560
84
+target7.y=230
85
+target8.height=50
86
+target8.name=Dog
87
+target8.showInterface=false
88
+target8.type=ClassTarget
89
+target8.width=80
90
+target8.x=580
91
+target8.y=250
92
+target9.height=50
93
+target9.name=Pet
94
+target9.showInterface=false
95
+target9.type=ClassTarget
96
+target9.width=80
97
+target9.x=384
98
+target9.y=93