SlideShare a Scribd company logo
1 of 9
JavaCode for Sample Projects
                                                         Inheritance Project
                Billing.java File

                        public Billing(Billing otherBilling)
                        {
                        invoiceNumber = "None Assigned";
                        }

                //create methods
                        public void setInvoiceNumber(String i)
                         {
                        invoiceNumber = i;
                         }

                        public String getinvoiceNumber()
                         {
                        returninvoiceNumber;
                         }
                        public void setVisitDate (String i)
                         {
                                 visitDate = i;
                         }

                        public String getVisitDate()
                         {
                        returnvisitDate;
                         }


Inheritance Project                                                            Page 1
public void setPatientSeen(Patient p)
                       {
                               patientSeen = p;
                       }
                      public Patient getPatientSeen()
                       {
                      returnpatientSeen;
                       }
                      public void setAttendingMD(Doctor d)
                       {
                               attendindgMD = d;
                       }
                      public Doctor getAttendingMD()
                       {
                      returnattendindgMD;
                       }
                      publicboolean equals(Billing other)
                       {
                               return (getVisitDate().equals(other.getVisitDate()) &&
                               ((getPatientSeen()).getBirthDate().equals((other.getPatientSeen()).getBirthDate())) &&
                               ((getPatientSeen()).getName().equals((other.getPatientSeen()).getName())) &&
                               ((getAttendingMD()).getName().equals((other.getAttendingMD()).getName())));
                       }
                      public void printInvoice()
                       {
                               System.out.println("MEDICAL CENTER INVOICE");
                               System.out.println(" ");
                               System.out.println("Invoice #"+ getinvoiceNumber());
                               System.out.println("Date of Service: " + getVisitDate());
                                System.out.println("Patient Name: " + getPatientSeen().getName() + " - ID Number: " +
                                        getPatientSeen().getPatientId());
                               System.out.println("Attending Physician: " + getAttendingMD().getName());
                               System.out.println("Amount Due for Office Visit: $" + getAttendingMD().getOfficeFee());
                       }
                }


Inheritance Project                                                                                                      Page 2
Doctor.java File
                public class Doctor extends Person
                {
                         //declare fields
                         String specialty;
                         String medSchool;
                         Double officeFee;

                        //set up constructors
                        public Doctor(String Name, String s, String ms, Double of)
                        {
                                 super(Name);
                                 specialty = s;
                                 medSchool =ms;
                                 officeFee = of;
                        }

                        public Doctor()
                        {
                                super();
                                specialty = "GP";
                                medSchool ="Unknown";
                                officeFee = 150.00;
                        }

                        public Doctor(Doctor otherDoctor)
                        {
                                super();
                                specialty = otherDoctor.specialty;
                                medSchool = otherDoctor.medSchool;
                                officeFee = otherDoctor.officeFee;

                        }




Inheritance Project                                                                  Page 3
//create methods

                public void setSpecialty(String sp)
                  {
                specialty = sp;
                  }
                public String getSpecialty()
                  {
                return specialty;
                  }
                public void setMedSchool(String m)
                  {
                medSchool = m;
                  }
                public String getMedSchool()
                  {
                returnmedSchool;
                  }
                public void setOfficeFee(Double f)
                  {
                officeFee = f;
                  }
                public Double getOfficeFee()
                  {
                returnofficeFee;
                  }
                publicboolean equals(Doctor other)
                  {
                         return (getName().equals(other.getName()));
                  }
                public void writeDoctorInfo()
                  {
                                System.out.println("Dr. " + getName() + " graduated from " + getMedSchool() + " and is a " + getSpecialty() + ". The
                                doctor's fee is $" + getOfficeFee() + " per visit.");
                  }
                }

Inheritance Project                                                                                                                               Page 4
Patient.java File

                public class Patient extends Person
                {
                String id;
                String birthdate;

                //set up constructors
                         public Patient(String Name, String i, String bD )
                         {
                                 super(Name);
                                 id = i;
                                 birthdate = bD;
                         }
                         public Patient()
                         {
                                 super();
                                 id ="Unknown";
                                 birthdate = "Month Day, Year";
                         }

                //create methods
                        public void setId(String i)
                        {
                        id = i;
                          }

                        public String getPatientId()
                        {
                        return id;
                         }

                        public void setBirthDate(String b)
                         {
                        birthdate= b;
                        }

Inheritance Project                                                          Page 5
public String getBirthDate()
                 {
                return birthdate;
                 }

                publicboolean equals(Patient other)
                  {
                        return (getName().equals(other.getName()) && (getBirthDate().equals(other.getBirthDate())));
                  }
                }




Inheritance Project                                                                                                    Page 6
Person.java File

                public class Person
                {
                         private String name;

                        public void setName(String newName)
                        {
                                 name = newName;
                        }

                        public Person()
                        {
                                name = "no name yet " ;
                        }

                        public Person(String initialName)
                        {
                                name = initialName;
                        }

                        public String getName()
                        {
                                 return name;
                        }

                        public void writeOutput()
                        {
                        System.out.println("Name: " + name);
                        }

                        publicbooleanhasSameName(Person otherPerson)
                        {
                        returnthis.name.equalsIgnoreCase(otherPerson.name);
                        }
                }

Inheritance Project                                                           Page 7
testDoctorMethods.java File

                public class testDoctorMethods
                {
                         public static void main(String[] args)
                         {
                                  //first constructor
                                  Doctor ManagingDirector = new Doctor();
                                  ManagingDirector.setName("Friedman");
                                  ManagingDirector.setMedSchool("Harvard");
                                  ManagingDirector.setSpecialty("Obstetrician");
                                  ManagingDirector.setOfficeFee(200.00);

                                //second constructor
                                Doctor Staff = new Doctor("Schwartz ", "Dermatologist", "John Hopkins", 150.00);

                                //third constructor
                                Doctor intern = new Doctor(Staff);
                                intern.setName("Schreiber");

                                //equals method
                                System.out.println("The Managing Director Doctor has the same name as the Staff Doctor is a " +
                                        ManagingDirector.hasSameName(Staff) + " statement!") ;

                                //report
                                System.out.println(" ");
                                System.out.println("First Doctor Constructor");
                                ManagingDirector.writeDoctorInfo();
                                System.out.println(" ");
                                System.out.println("Second Doctor Constructor");
                                Staff.writeDoctorInfo();
                                System.out.println(" ");
                                System.out.println("Third Doctor Constructor");
                                intern.writeDoctorInfo();
                        }
                }

Inheritance Project                                                                                                               Page 8
testPatientBillingMethods.java File

                public class testPatientBillingMethods
                {
                         public static void main(String[] args)
                         {
                                  //declare invoice total variable
                                  Double totalInvoices;
                                  //re-create doctor
                                  Doctor Staff = new Doctor("Dr. Schwartz ", "Dermatologist", "John Hopkins", 150.00);
                                  // create new patients
                                  Patient johnDoe = new Patient("John Doe", "000001", "January 11, 1971");
                                  Patient marySmith = new Patient("Mary Smith", "000002", "May 11, 1975");
                                  //create billing objects
                                  Billing i00001 = new Billing(johnDoe, Staff, "i00001", "May 1, 2012");
                                  Billing i00002 = new Billing(marySmith, Staff, "i00002", "May 1, 2012");
                                  //verify that the 2 billing records are not duplicates
                                  if (i00001.equals(i00002) == true)
                                            {
                                            System.out.println("These 2 billing records are for the same patient visit ");
                                            }
                                  else
                                            {
                                            System.out.println("These 2 billing records are NOT for the same patient visit ");
                                            }
                                  System.out.println(" ");
                                  //generate invoices for patient visits
                                  i00001.printInvoice();
                                  System.out.println(" ");
                                  i00002.printInvoice();
                                  //generate total of invoices
                                  totalInvoices = (i00001.getAttendingMD().getOfficeFee() + i00002.getAttendingMD().getOfficeFee() );
                                  System.out.println(" ");
                                  System.out.println("Total Office Receipts for May 1, 2012 were: $" + totalInvoices);
                         }
                }

Inheritance Project                                                                                                                     Page 9

More Related Content

What's hot

Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classesasadsardar
 
Java 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesJava 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesGanesh Samarthyam
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In JavaManish Sahu
 
Tutorial para Desenvolvimento Mobile usando HTML CSS e Javascript
Tutorial para Desenvolvimento Mobile usando HTML CSS e JavascriptTutorial para Desenvolvimento Mobile usando HTML CSS e Javascript
Tutorial para Desenvolvimento Mobile usando HTML CSS e JavascriptWillys Campos
 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oopsHirra Sultan
 
Class and Objects in PHP
Class and Objects in PHPClass and Objects in PHP
Class and Objects in PHPRamasubbu .P
 
Introduction to SQLAlchemy ORM
Introduction to SQLAlchemy ORMIntroduction to SQLAlchemy ORM
Introduction to SQLAlchemy ORMJason Myers
 
Java Serialization
Java SerializationJava Serialization
Java Serializationjeslie
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/ServletSunil OS
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaRahulAnanda1
 
Effective Java and Kotlin
Effective Java and KotlinEffective Java and Kotlin
Effective Java and Kotlin경주 전
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Kamlesh Makvana
 
[2019] Spring JPA의 사실과 오해
[2019] Spring JPA의 사실과 오해[2019] Spring JPA의 사실과 오해
[2019] Spring JPA의 사실과 오해NHN FORWARD
 

What's hot (20)

Friends function and_classes
Friends function and_classesFriends function and_classes
Friends function and_classes
 
Java 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional InterfacesJava 8 Lambda Built-in Functional Interfaces
Java 8 Lambda Built-in Functional Interfaces
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Tutorial para Desenvolvimento Mobile usando HTML CSS e Javascript
Tutorial para Desenvolvimento Mobile usando HTML CSS e JavascriptTutorial para Desenvolvimento Mobile usando HTML CSS e Javascript
Tutorial para Desenvolvimento Mobile usando HTML CSS e Javascript
 
Introduction à JPA (Java Persistence API )
Introduction à JPA  (Java Persistence API )Introduction à JPA  (Java Persistence API )
Introduction à JPA (Java Persistence API )
 
Inheritance in oops
Inheritance in oopsInheritance in oops
Inheritance in oops
 
Class and Objects in PHP
Class and Objects in PHPClass and Objects in PHP
Class and Objects in PHP
 
09. Java Methods
09. Java Methods09. Java Methods
09. Java Methods
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
Introduction to SQLAlchemy ORM
Introduction to SQLAlchemy ORMIntroduction to SQLAlchemy ORM
Introduction to SQLAlchemy ORM
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
OOP V3.1
OOP V3.1OOP V3.1
OOP V3.1
 
Effective Java and Kotlin
Effective Java and KotlinEffective Java and Kotlin
Effective Java and Kotlin
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
Core java
Core java Core java
Core java
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
 
[2019] Spring JPA의 사실과 오해
[2019] Spring JPA의 사실과 오해[2019] Spring JPA의 사실과 오해
[2019] Spring JPA의 사실과 오해
 

Viewers also liked

Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical FileSoumya Behera
 
Advanced java practical semester 6_computer science
Advanced java practical semester 6_computer scienceAdvanced java practical semester 6_computer science
Advanced java practical semester 6_computer scienceNiraj Bharambe
 
Hospital management system in java
Hospital management system in javaHospital management system in java
Hospital management system in javaVarun Yadav
 
Hospital management system project
Hospital management system projectHospital management system project
Hospital management system projectHimani Chopra
 
Java questions for viva
Java questions for vivaJava questions for viva
Java questions for vivaVipul Naik
 
31911477 internet-banking-project-documentation
31911477 internet-banking-project-documentation31911477 internet-banking-project-documentation
31911477 internet-banking-project-documentationSwaroop Mane
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobGaruda Trainings
 
Hard copy of proj doc
Hard copy of proj docHard copy of proj doc
Hard copy of proj docnawaldiatm
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALPrabhu D
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Nishan Barot
 
Bank management system with java
Bank management system with java Bank management system with java
Bank management system with java Neha Bhagat
 
Human Resource Management System Java Project
Human Resource Management System Java ProjectHuman Resource Management System Java Project
Human Resource Management System Java ProjectTutorial Learners
 

Viewers also liked (20)

Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
 
Java codes
Java codesJava codes
Java codes
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
Advanced java practical semester 6_computer science
Advanced java practical semester 6_computer scienceAdvanced java practical semester 6_computer science
Advanced java practical semester 6_computer science
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Hospital management system
Hospital management systemHospital management system
Hospital management system
 
Hospital management system in java
Hospital management system in javaHospital management system in java
Hospital management system in java
 
Hospital management system project
Hospital management system projectHospital management system project
Hospital management system project
 
Java questions for viva
Java questions for vivaJava questions for viva
Java questions for viva
 
31911477 internet-banking-project-documentation
31911477 internet-banking-project-documentation31911477 internet-banking-project-documentation
31911477 internet-banking-project-documentation
 
Basic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a jobBasic java important interview questions and answers to secure a job
Basic java important interview questions and answers to secure a job
 
At a glance
At a glanceAt a glance
At a glance
 
Hard copy of proj doc
Hard copy of proj docHard copy of proj doc
Hard copy of proj doc
 
Bank account in java
Bank account in javaBank account in java
Bank account in java
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.Final JAVA Practical of BCA SEM-5.
Final JAVA Practical of BCA SEM-5.
 
Bank management system with java
Bank management system with java Bank management system with java
Bank management system with java
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
Human Resource Management System Java Project
Human Resource Management System Java ProjectHuman Resource Management System Java Project
Human Resource Management System Java Project
 

Similar to Java Code for Sample Projects Inheritance

Hello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfHello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfbarristeressaseren71
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo....NET Conf UY
 
20070329 Object Oriented Programing Tips
20070329 Object Oriented Programing Tips20070329 Object Oriented Programing Tips
20070329 Object Oriented Programing TipsShingo Furuyama
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good codeGiordano Scalzo
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в JavaDEVTYPE
 
Testdrevet javautvikling på objektorienterte skinner
Testdrevet javautvikling på objektorienterte skinnerTestdrevet javautvikling på objektorienterte skinner
Testdrevet javautvikling på objektorienterte skinnerTruls Jørgensen
 
Implementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBImplementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBOren Eini
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeDaniel Wellman
 
Project .javaimport java.util.;public class Project impleme.pdf
Project .javaimport java.util.;public class Project impleme.pdfProject .javaimport java.util.;public class Project impleme.pdf
Project .javaimport java.util.;public class Project impleme.pdfaquacosmossystems
 
Patient.java package A9.toStudents; public class Patient imple.pdf
Patient.java package A9.toStudents; public class Patient imple.pdfPatient.java package A9.toStudents; public class Patient imple.pdf
Patient.java package A9.toStudents; public class Patient imple.pdfDEEPAKSONI562
 
CDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCaelum
 
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietySOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietyChris Weldon
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBtdc-globalcode
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 

Similar to Java Code for Sample Projects Inheritance (20)

Hello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfHello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdf
 
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
Code Smells y Refactoring o haciendo que nuestro codigo huela (y se vea) mejo...
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
20070329 Object Oriented Programing Tips
20070329 Object Oriented Programing Tips20070329 Object Oriented Programing Tips
20070329 Object Oriented Programing Tips
 
Better Software: introduction to good code
Better Software: introduction to good codeBetter Software: introduction to good code
Better Software: introduction to good code
 
Mattbrenner
MattbrennerMattbrenner
Mattbrenner
 
Lecture21
Lecture21Lecture21
Lecture21
 
Vaadin 7
Vaadin 7Vaadin 7
Vaadin 7
 
Test Engine
Test EngineTest Engine
Test Engine
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
 
Testdrevet javautvikling på objektorienterte skinner
Testdrevet javautvikling på objektorienterte skinnerTestdrevet javautvikling på objektorienterte skinner
Testdrevet javautvikling på objektorienterte skinner
 
Implementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBImplementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDB
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
Project .javaimport java.util.;public class Project impleme.pdf
Project .javaimport java.util.;public class Project impleme.pdfProject .javaimport java.util.;public class Project impleme.pdf
Project .javaimport java.util.;public class Project impleme.pdf
 
Patient.java package A9.toStudents; public class Patient imple.pdf
Patient.java package A9.toStudents; public class Patient imple.pdfPatient.java package A9.toStudents; public class Patient imple.pdf
Patient.java package A9.toStudents; public class Patient imple.pdf
 
Test Engine
Test EngineTest Engine
Test Engine
 
CDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptor
 
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietySOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 

More from jwjablonski

Amazing Books Database Objects, Reports and Forms
Amazing Books Database Objects, Reports and FormsAmazing Books Database Objects, Reports and Forms
Amazing Books Database Objects, Reports and Formsjwjablonski
 
Study Skills Project
Study Skills ProjectStudy Skills Project
Study Skills Projectjwjablonski
 
Java Code For Sample Projects I/O
Java Code For Sample Projects I/OJava Code For Sample Projects I/O
Java Code For Sample Projects I/Ojwjablonski
 
Java Code for Sample Projects Loops
Java Code for Sample Projects LoopsJava Code for Sample Projects Loops
Java Code for Sample Projects Loopsjwjablonski
 
Java Code for Sample Projects Methods
Java Code for Sample Projects MethodsJava Code for Sample Projects Methods
Java Code for Sample Projects Methodsjwjablonski
 
VBA Final Project
VBA Final ProjectVBA Final Project
VBA Final Projectjwjablonski
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projectsjwjablonski
 
Animal Shelter Database Presentation
Animal Shelter Database PresentationAnimal Shelter Database Presentation
Animal Shelter Database Presentationjwjablonski
 

More from jwjablonski (11)

Portfolio
PortfolioPortfolio
Portfolio
 
Amazing Books Database Objects, Reports and Forms
Amazing Books Database Objects, Reports and FormsAmazing Books Database Objects, Reports and Forms
Amazing Books Database Objects, Reports and Forms
 
Study Skills Project
Study Skills ProjectStudy Skills Project
Study Skills Project
 
Java Code For Sample Projects I/O
Java Code For Sample Projects I/OJava Code For Sample Projects I/O
Java Code For Sample Projects I/O
 
Java Code for Sample Projects Loops
Java Code for Sample Projects LoopsJava Code for Sample Projects Loops
Java Code for Sample Projects Loops
 
Java Code for Sample Projects Methods
Java Code for Sample Projects MethodsJava Code for Sample Projects Methods
Java Code for Sample Projects Methods
 
VBA Final Project
VBA Final ProjectVBA Final Project
VBA Final Project
 
PL/SQL Code for Sample Projects
PL/SQL Code for Sample ProjectsPL/SQL Code for Sample Projects
PL/SQL Code for Sample Projects
 
Animal Shelter Database Presentation
Animal Shelter Database PresentationAnimal Shelter Database Presentation
Animal Shelter Database Presentation
 
Hangman Program
Hangman ProgramHangman Program
Hangman Program
 
Cents Add Up
Cents Add Up Cents Add Up
Cents Add Up
 

Recently uploaded

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 

Recently uploaded (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 

Java Code for Sample Projects Inheritance

  • 1. JavaCode for Sample Projects Inheritance Project Billing.java File public Billing(Billing otherBilling) { invoiceNumber = "None Assigned"; } //create methods public void setInvoiceNumber(String i) { invoiceNumber = i; } public String getinvoiceNumber() { returninvoiceNumber; } public void setVisitDate (String i) { visitDate = i; } public String getVisitDate() { returnvisitDate; } Inheritance Project Page 1
  • 2. public void setPatientSeen(Patient p) { patientSeen = p; } public Patient getPatientSeen() { returnpatientSeen; } public void setAttendingMD(Doctor d) { attendindgMD = d; } public Doctor getAttendingMD() { returnattendindgMD; } publicboolean equals(Billing other) { return (getVisitDate().equals(other.getVisitDate()) && ((getPatientSeen()).getBirthDate().equals((other.getPatientSeen()).getBirthDate())) && ((getPatientSeen()).getName().equals((other.getPatientSeen()).getName())) && ((getAttendingMD()).getName().equals((other.getAttendingMD()).getName()))); } public void printInvoice() { System.out.println("MEDICAL CENTER INVOICE"); System.out.println(" "); System.out.println("Invoice #"+ getinvoiceNumber()); System.out.println("Date of Service: " + getVisitDate()); System.out.println("Patient Name: " + getPatientSeen().getName() + " - ID Number: " + getPatientSeen().getPatientId()); System.out.println("Attending Physician: " + getAttendingMD().getName()); System.out.println("Amount Due for Office Visit: $" + getAttendingMD().getOfficeFee()); } } Inheritance Project Page 2
  • 3. Doctor.java File public class Doctor extends Person { //declare fields String specialty; String medSchool; Double officeFee; //set up constructors public Doctor(String Name, String s, String ms, Double of) { super(Name); specialty = s; medSchool =ms; officeFee = of; } public Doctor() { super(); specialty = "GP"; medSchool ="Unknown"; officeFee = 150.00; } public Doctor(Doctor otherDoctor) { super(); specialty = otherDoctor.specialty; medSchool = otherDoctor.medSchool; officeFee = otherDoctor.officeFee; } Inheritance Project Page 3
  • 4. //create methods public void setSpecialty(String sp) { specialty = sp; } public String getSpecialty() { return specialty; } public void setMedSchool(String m) { medSchool = m; } public String getMedSchool() { returnmedSchool; } public void setOfficeFee(Double f) { officeFee = f; } public Double getOfficeFee() { returnofficeFee; } publicboolean equals(Doctor other) { return (getName().equals(other.getName())); } public void writeDoctorInfo() { System.out.println("Dr. " + getName() + " graduated from " + getMedSchool() + " and is a " + getSpecialty() + ". The doctor's fee is $" + getOfficeFee() + " per visit."); } } Inheritance Project Page 4
  • 5. Patient.java File public class Patient extends Person { String id; String birthdate; //set up constructors public Patient(String Name, String i, String bD ) { super(Name); id = i; birthdate = bD; } public Patient() { super(); id ="Unknown"; birthdate = "Month Day, Year"; } //create methods public void setId(String i) { id = i; } public String getPatientId() { return id; } public void setBirthDate(String b) { birthdate= b; } Inheritance Project Page 5
  • 6. public String getBirthDate() { return birthdate; } publicboolean equals(Patient other) { return (getName().equals(other.getName()) && (getBirthDate().equals(other.getBirthDate()))); } } Inheritance Project Page 6
  • 7. Person.java File public class Person { private String name; public void setName(String newName) { name = newName; } public Person() { name = "no name yet " ; } public Person(String initialName) { name = initialName; } public String getName() { return name; } public void writeOutput() { System.out.println("Name: " + name); } publicbooleanhasSameName(Person otherPerson) { returnthis.name.equalsIgnoreCase(otherPerson.name); } } Inheritance Project Page 7
  • 8. testDoctorMethods.java File public class testDoctorMethods { public static void main(String[] args) { //first constructor Doctor ManagingDirector = new Doctor(); ManagingDirector.setName("Friedman"); ManagingDirector.setMedSchool("Harvard"); ManagingDirector.setSpecialty("Obstetrician"); ManagingDirector.setOfficeFee(200.00); //second constructor Doctor Staff = new Doctor("Schwartz ", "Dermatologist", "John Hopkins", 150.00); //third constructor Doctor intern = new Doctor(Staff); intern.setName("Schreiber"); //equals method System.out.println("The Managing Director Doctor has the same name as the Staff Doctor is a " + ManagingDirector.hasSameName(Staff) + " statement!") ; //report System.out.println(" "); System.out.println("First Doctor Constructor"); ManagingDirector.writeDoctorInfo(); System.out.println(" "); System.out.println("Second Doctor Constructor"); Staff.writeDoctorInfo(); System.out.println(" "); System.out.println("Third Doctor Constructor"); intern.writeDoctorInfo(); } } Inheritance Project Page 8
  • 9. testPatientBillingMethods.java File public class testPatientBillingMethods { public static void main(String[] args) { //declare invoice total variable Double totalInvoices; //re-create doctor Doctor Staff = new Doctor("Dr. Schwartz ", "Dermatologist", "John Hopkins", 150.00); // create new patients Patient johnDoe = new Patient("John Doe", "000001", "January 11, 1971"); Patient marySmith = new Patient("Mary Smith", "000002", "May 11, 1975"); //create billing objects Billing i00001 = new Billing(johnDoe, Staff, "i00001", "May 1, 2012"); Billing i00002 = new Billing(marySmith, Staff, "i00002", "May 1, 2012"); //verify that the 2 billing records are not duplicates if (i00001.equals(i00002) == true) { System.out.println("These 2 billing records are for the same patient visit "); } else { System.out.println("These 2 billing records are NOT for the same patient visit "); } System.out.println(" "); //generate invoices for patient visits i00001.printInvoice(); System.out.println(" "); i00002.printInvoice(); //generate total of invoices totalInvoices = (i00001.getAttendingMD().getOfficeFee() + i00002.getAttendingMD().getOfficeFee() ); System.out.println(" "); System.out.println("Total Office Receipts for May 1, 2012 were: $" + totalInvoices); } } Inheritance Project Page 9