Browse Source

Upload files to 'Pets'

master
ericorahmad1 1 year ago
parent
commit
05d2bd030d
5 changed files with 268 additions and 0 deletions
  1. 46
    0
      Pets/Cat.java
  2. 47
    0
      Pets/Dog.java
  3. 47
    0
      Pets/Dose.java
  4. 79
    0
      Pets/Pet.java
  5. 49
    0
      Pets/VetClinic.java

+ 46
- 0
Pets/Cat.java View File

@@ -0,0 +1,46 @@
1
+import java.util.*;
2
+
3
+public class Cat extends Pet {
4
+	
5
+	private boolean allergic;
6
+
7
+	public Cat(){
8
+		
9
+	}
10
+	public Cat(int petId, String name, double weight, Date dob, double accumulatedDose, boolean allergic){
11
+		super(petId, name, weight, dob, accumulatedDose);
12
+		this.allergic = allergic;
13
+	}
14
+//Setter
15
+	public void setAllergic(boolean allergic){
16
+		this.allergic = allergic;
17
+	}
18
+
19
+//Getter
20
+	public boolean getAllergic(){
21
+		return this.allergic;
22
+	}
23
+
24
+	public double getDose(){
25
+		if ( getAccumulatedDose() > 500) {
26
+			return 0;
27
+		
28
+		// }else if(getAllergic() == true){
29
+		// 	return 0;
30
+		// }else if( findAge() >3 && weight > 0.5){
31
+		// 	return 7+0.61* getWeight();
32
+		}else{
33
+			return 0.81 * getWeight();
34
+		}
35
+	}
36
+
37
+	public String toString(){
38
+		return  "petID=" + getPetId() +
39
+                ", name='" + getName() + '\'' +
40
+                ", weight=" + getWeight() +
41
+                // ", dob=" + VetClinicConsole.dateToStr(getDob()) +
42
+                // ", accumulatedDose=" + getAccumulatedDose() +
43
+                ",allergic='" + allergic + '\'';
44
+	}
45
+
46
+}

+ 47
- 0
Pets/Dog.java View File

@@ -0,0 +1,47 @@
1
+import java.util.*;
2
+public class Dog extends Pet {
3
+	
4
+	private String breed;
5
+
6
+	public Dog(){
7
+		super();
8
+		this.breed = "";
9
+	}
10
+
11
+	public Dog(int petId, String name, double weight, Date dob, double accumulatedDose, String breed){
12
+		super(petId, name, weight, dob, accumulatedDose);
13
+		this.breed = breed;
14
+	}
15
+
16
+//Setter 
17
+	public void setBreed(String breed){
18
+		this.breed = breed;
19
+	}
20
+
21
+//Getter 
22
+	public String getBreed(){
23
+		return this.breed;
24
+	}
25
+
26
+	public double getDose(){
27
+		if (getAccumulatedDose() > 750){
28
+			return 0;
29
+		// }else if( findAge() < 3){
30
+		// 	return 0;
31
+		// }else if(findAge() > 12 && getWeight() <2){
32
+		// 	return 6 + 0.75 * getWeight();
33
+		}else{
34
+			return 12 + 0.65* getWeight();
35
+		}
36
+	}
37
+
38
+	public String toString(){
39
+		return  "petID=" + getPetId() +
40
+                ", name='" + getName() + '\'' +
41
+                ", weight=" + getWeight() +
42
+                // ", dob=" + VetClinicConsole.dateToStr(getDob()) +
43
+                // ", accumulatedDose=" + getAccumulatedDose() +
44
+                ",breed='" + breed + '\'';
45
+	}
46
+
47
+}

+ 47
- 0
Pets/Dose.java View File

@@ -0,0 +1,47 @@
1
+import java.util.*;
2
+
3
+public class Dose {
4
+
5
+	private String nameOfDrug;
6
+	private Date date;
7
+	private double doseInGrams;
8
+
9
+	public Dose(){
10
+		this.nameOfDrug = "";
11
+		Date date = new Date();
12
+		this.date = date;
13
+		this.doseInGrams = 0.0;
14
+	}
15
+
16
+	public Dose(String nameOfDrug, double doseInGrams){
17
+		Date date = new Date();
18
+		this.date = date;
19
+		this.nameOfDrug = nameOfDrug;
20
+		this.doseInGrams = doseInGrams;
21
+	}
22
+
23
+	//Setter
24
+	public void setNameOfDrug(String nameOfDrug){
25
+		this.nameOfDrug = nameOfDrug;
26
+	}
27
+
28
+	public void setDate(Date date){
29
+		this.date = date;
30
+	}
31
+
32
+	public void setDoseInGrams(double doseInGrams){
33
+		this.doseInGrams = doseInGrams;
34
+	}
35
+
36
+	//Getter
37
+	public String getNameOfDrug(){
38
+		return this.nameOfDrug;
39
+	}
40
+
41
+	public Date getDate(){
42
+		return this.date;
43
+	}
44
+	public double getDoseInGrams(){
45
+		return this.doseInGrams;
46
+	}
47
+}

+ 79
- 0
Pets/Pet.java View File

@@ -0,0 +1,79 @@
1
+import java.util.*;
2
+
3
+public abstract class Pet {
4
+	private int petId;
5
+	private String name;
6
+	private double weight;
7
+	private Date dob;
8
+	private Double accumulatedDose;
9
+
10
+	private ArrayList<Dose> doses;
11
+
12
+//Constructor
13
+	public Pet(){
14
+		this.doses = new ArrayList<Dose>();
15
+	}
16
+
17
+	public Pet(int petId, String name, double weight, Date dob, double accumulatedDose){
18
+		this.petId = petId;
19
+		this.name = name;
20
+		this.weight = weight;
21
+		this.dob = dob;
22
+		this.accumulatedDose = accumulatedDose;
23
+
24
+		this.doses = new ArrayList<Dose>();
25
+
26
+	}
27
+
28
+	// Setter
29
+	public void setPetId(int petId){
30
+		this.petId = petId;
31
+	}
32
+	public void setName(String name){
33
+		this.name = name;
34
+	}
35
+	public void setWeight(double weight){
36
+		this.weight = weight;
37
+	}
38
+	public void setDob(Date dob){
39
+		this.dob = dob;
40
+	}
41
+	public void accumulatedDose(double accumulatedDose){
42
+		this.accumulatedDose = accumulatedDose;
43
+	}
44
+
45
+	public void setDoses(ArrayList<Dose> doses){
46
+		this.doses = doses;
47
+	}
48
+
49
+	// Getter
50
+	public int getPetId(){
51
+		return this.petId;
52
+	}
53
+	public String getName(){
54
+		return this.name;
55
+	}
56
+	public double getWeight(){
57
+		return this.weight;
58
+	}
59
+	public Date getDob(){
60
+		return this.dob;
61
+	}
62
+	public double getAccumulatedDose(){
63
+		return this.accumulatedDose;
64
+	}
65
+	public ArrayList<Dose> getDoses(){
66
+		return this.doses;
67
+	}
68
+
69
+	public int findAge(){
70
+	int differentMonth = 0;	
71
+	Date firstDate = this.dob;
72
+	Date secondDate = new Date();
73
+	
74
+	}
75
+
76
+
77
+	// public abstract double getDose();
78
+
79
+}

+ 49
- 0
Pets/VetClinic.java View File

@@ -0,0 +1,49 @@
1
+import java.util.*;
2
+
3
+public class VetClinic {
4
+	
5
+	private static Scanner scan;
6
+	private static int petId = 1;
7
+
8
+	public static void main(String[] args) {
9
+		ArrayList<Pet> pets = new ArrayList<Pet>;
10
+		scan = new Scanner(System.in);
11
+		public static void printMainMenu();{
12
+			System.out.println("1. Adding a Pet ");
13
+			System.out.println("2. Delete a Pet");
14
+			System.out.println("3. Show all Pet(s)!");
15
+			System.out.println("4. Add a drug for a Pet ");
16
+			System.out.println("5. Edit information Pet ");
17
+			System.out.println("6. Quit \n ");
18
+			System.out.println("Your Choice: ");
19
+
20
+		}
21
+
22
+		int choose = scan.nextLine();
23
+		while (choose!= 0){
24
+			switch(choose){
25
+				case 1:
26
+					printChoicePet();
27
+
28
+
29
+				case 2:
30
+
31
+
32
+				case 3:
33
+
34
+
35
+				case 4:
36
+
37
+
38
+
39
+				case 5:
40
+
41
+
42
+				case 6:
43
+
44
+
45
+			}
46
+		}
47
+
48
+	}
49
+}

Loading…
Cancel
Save