diff --git a/OOP_Chalenge/OOP_Chalenge.iml b/OOP_Chalenge/OOP_Chalenge.iml new file mode 100644 index 0000000..9465dd8 --- /dev/null +++ b/OOP_Chalenge/OOP_Chalenge.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Eye.class b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Eye.class new file mode 100644 index 0000000..c368512 Binary files /dev/null and b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Eye.class differ diff --git a/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Heart.class b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Heart.class new file mode 100644 index 0000000..404fc58 Binary files /dev/null and b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Heart.class differ diff --git a/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Main.class b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Main.class new file mode 100644 index 0000000..863f16b Binary files /dev/null and b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Main.class differ diff --git a/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Organ.class b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Organ.class new file mode 100644 index 0000000..9ee4cc9 Binary files /dev/null and b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Organ.class differ diff --git a/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Patient.class b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Patient.class new file mode 100644 index 0000000..9d0a96e Binary files /dev/null and b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Patient.class differ diff --git a/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Skin.class b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Skin.class new file mode 100644 index 0000000..2d6b678 Binary files /dev/null and b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Skin.class differ diff --git a/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Stomach.class b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Stomach.class new file mode 100644 index 0000000..766e1dd Binary files /dev/null and b/OOP_Chalenge/out/production/OOP_Chalenge/com/company/Stomach.class differ diff --git a/OOP_Chalenge/src/com/company/Eye.java b/OOP_Chalenge/src/com/company/Eye.java new file mode 100644 index 0000000..a44db16 --- /dev/null +++ b/OOP_Chalenge/src/com/company/Eye.java @@ -0,0 +1,41 @@ +package com.company; + +public class Eye extends Organ { + private String colour; // the colour of the eye + private boolean openeye; // to know if the eye is open or not + + public Eye(String name, String medicalState, String colour, boolean openeye) { + super(name, medicalState); + this.colour = colour; + this.openeye = openeye; + } + + @Override + public void getInfo() { + super.getInfo(); + System.out.println("Colour " + getColour()); + } + + public void Open () { + this.setOpeneye(true); + System.out.println(this.getName() +" Opened"); + } + + public void Close () { + this.setOpeneye(false); + System.out.println(this.getName() + " Closed"); + } + + public String getColour() { + return colour; + } + + + public boolean isOpeneye() { + return openeye; + } + + public void setOpeneye(boolean openeye) { + this.openeye = openeye; + } +} diff --git a/OOP_Chalenge/src/com/company/Heart.java b/OOP_Chalenge/src/com/company/Heart.java new file mode 100644 index 0000000..a11949d --- /dev/null +++ b/OOP_Chalenge/src/com/company/Heart.java @@ -0,0 +1,25 @@ +package com.company; + +public class Heart extends Organ { + + private int rate; // Heart Rate + + public Heart(String name, String medicalState, int rate) { + super(name, medicalState); + this.rate = rate; + } + + @Override + public void getInfo() { + super.getInfo(); + System.out.println("Heart Rate: " + this.getRate()); + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } +} diff --git a/OOP_Chalenge/src/com/company/Main.java b/OOP_Chalenge/src/com/company/Main.java new file mode 100644 index 0000000..2ba591e --- /dev/null +++ b/OOP_Chalenge/src/com/company/Main.java @@ -0,0 +1,111 @@ +package com.company; + +import java.util.Scanner; + +public class Main { + // this is the min class where we would be instantiating all the classes + + public static void main(String[] args) { + Patient patient = new Patient("Segun Adebayo", 21, + new Eye("Left Eye", "Short Sighted", "Brown", true), + new Eye("Right Eye", "Normal", "Brown", true), + new Heart("Heart", "Normal", 68), + new Stomach("Stomach","Ulcer", false), + new Skin("Skin", "Ecdysis", "Brown", 40/100)); + + System.out.println("Name: " + patient.getName()); + System.out.println("Age: " + patient.getAge()); + + Scanner scanner = new Scanner(System.in); + + boolean shouldFinish = false; + + while (!shouldFinish) { + System.out.println("Choose an Organ to examine:" + + "\n\t1. Left Eye" + + "\n\t2. Right Eye" + + "\n\t3. Heart" + + "\n\t4. Stomach" + + "\n\t5. Skin" + + "\n\t6. Stop the Program (Quit)"); // the backslash n moves the cursor to the next line + + int choice = scanner.nextInt(); + + switch (choice) { + case 1: // If user picks the Left Eye + patient.getLeftEye().getInfo(); + if (patient.getLeftEye().isOpeneye()) { + System.out.println("\t\t1. Close the Eye"); + if (scanner.nextInt() == 1) { + patient.getLeftEye().Close(); + } else { + continue; + } + } else { + System.out.println("\t\t1. Open the Eye"); + if (scanner.nextInt() == 1) { + patient.getLeftEye().Open(); + }else { + continue; + } + } + + break; + + + case 2: // If user picks the Right Eye + patient.getRightEye().getInfo(); + if (patient.getRightEye().isOpeneye()) { + System.out.println("\t\t1. Close the Eye"); + if (scanner.nextInt() == 1) { + patient.getRightEye().Close(); + } else { + continue; + } + } else { + System.out.println("\t\t1. Open the Eye"); + if (scanner.nextInt() == 1) { + patient.getRightEye().Open(); + }else { + continue; + } + } + + break; + + case 3: // if user picks the heart + patient.getHeart().getInfo(); + System.out.println("\t\t1. Check and Change the Heart Rate"); + + if (scanner.nextInt() == 1) { + System.out.println("Enter the new Heart Rate"); // to change heart rate + int newHeartRate = scanner.nextInt(); + patient.getHeart().setRate(newHeartRate); + System.out.println("Heart Rate has been changed successfully"); + System.out.println("Your heart rate is now " + patient.getHeart().getRate()); + } else { + continue; + } + break; + case 4: + patient.getStomach().getInfo(); + System.out.println("\t\t1. Digest"); + if (scanner.nextInt() == 1) { + patient.getStomach().Digest(); + }else { + continue; + } + break; + + + case 5: + patient.getSkin().getInfo(); + break; + + default: + shouldFinish = true; + break; + } + } + } +} diff --git a/OOP_Chalenge/src/com/company/Organ.java b/OOP_Chalenge/src/com/company/Organ.java new file mode 100644 index 0000000..6c0499c --- /dev/null +++ b/OOP_Chalenge/src/com/company/Organ.java @@ -0,0 +1,31 @@ +package com.company; + +public class Organ { + // With this application i would be showing a patients name and each of his internal organs we can select and the details of the organs and also give the doctors to close or open the organs + + private String name; // name of the patient + private String medicalState; // the medical condition of the patient + + + public Organ(String name, String medicalState) { + this.name = name; + this.medicalState = medicalState; + } + + public void getInfo () { + System.out.println("Name: " + this.getName()); + System.out.println("Medical Condition: " + this.getMedicalState()); + } + + public String getName() { + return name; + } + + + + public String getMedicalState() { + return medicalState; + } + + +} diff --git a/OOP_Chalenge/src/com/company/Patient.java b/OOP_Chalenge/src/com/company/Patient.java new file mode 100644 index 0000000..d7a2284 --- /dev/null +++ b/OOP_Chalenge/src/com/company/Patient.java @@ -0,0 +1,57 @@ +package com.company; + +public class Patient { + + private String name; + private int Age; + private Eye leftEye; + private Eye rightEye; + private Heart heart; + private Stomach stomach; + private Skin skin; + + + public Patient(String name, int age, Eye leftEye, Eye rightEye, Heart heart, Stomach stomach, Skin skin) { + this.name = name; + Age = age; + this.leftEye = leftEye; + this.rightEye = rightEye; + this.heart = heart; + this.stomach = stomach; + this.skin = skin; + } + + + public String getName() { + return name; + } + + + public int getAge() { + return Age; + } + + + public Eye getLeftEye() { + return leftEye; + } + + + public Eye getRightEye() { + return rightEye; + } + + public Heart getHeart() { + return heart; + } + + + public Stomach getStomach() { + return stomach; + } + + public Skin getSkin() { + return skin; + } + +} diff --git a/OOP_Chalenge/src/com/company/Skin.java b/OOP_Chalenge/src/com/company/Skin.java new file mode 100644 index 0000000..f235b47 --- /dev/null +++ b/OOP_Chalenge/src/com/company/Skin.java @@ -0,0 +1,24 @@ +package com.company; + +public class Skin extends Organ { + + private String colour; // the colour of the skin of the patient + private int softness; // the softness of the skin of the patient + + public Skin(String name, String medicalState, String colour, int softness) { + super(name, medicalState); + this.colour = colour; + this.softness = softness; + } + + @Override + public void getInfo() { + super.getInfo(); + + System.out.println("Skin Colour" + this.getColour()); + } + + public String getColour() { + return colour; + } +} diff --git a/OOP_Chalenge/src/com/company/Stomach.java b/OOP_Chalenge/src/com/company/Stomach.java new file mode 100644 index 0000000..f7a54b3 --- /dev/null +++ b/OOP_Chalenge/src/com/company/Stomach.java @@ -0,0 +1,31 @@ +package com.company; + +public class Stomach extends Organ { + + private boolean isEmpty; // to show if the stomach is empty + + public Stomach(String name, String medicalState, boolean isEmpty) { + super(name, medicalState); + this.isEmpty = isEmpty; + } + + public void Digest() { // to show if the parents digest his food + System.out.println("Food digestion ongoing"); + } + + @Override + public void getInfo() { + super.getInfo(); // we would create a loop to avaoid getting errors + + if (this.isEmpty()) { + System.out.println("Feed the Patient"); + } else { + System.out.println("Patient Eating capacity is full"); + } + } + + public boolean isEmpty() { + return isEmpty; + } + +}

AltStyle によって変換されたページ (->オリジナル) /