Question

In: Computer Science

Problem 2: (20 pts) Create a Patient class which has private fields for patientid, lastname, firstname,...

Problem 2:

(20 pts) Create a Patient class which has private fields for patientid, lastname,

firstname, age, and email. Create public data items for each of these private fields with get and

set methods. The entire lastname must be stored in uppercase. Create a main class which

instantiates a patient object and sets values for each data item within the class. Display the

data in the object to the console window

Solutions

Expert Solution

Patient class

Main class

Console Window

You can copy code from below.

package com.company;

public class patient {
    private String patientid;
    private String lastname;
    private String firstname;
    private int age;
    private String email;

    //getters
    public String getPatientid() {
        return patientid;
    }

    public String getLastname() {
        return lastname;
    }

    public String getFirstname() {
        return firstname;
    }

    public int getAge() {
        return age;
    }

    public String getEmail() {
        return email;
    }

    // setters
    public void setPatientid(String patientid) {
        this.patientid = patientid;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setEmail(String email) {
        this.email = email.toUpperCase(); //stored in uppercase
    }

    public void display() {
        System.out.println("Patient ID: " + patientid);
        System.out.println("Name: " + firstname + " " + lastname);
        System.out.println("Age: " + age);
        System.out.println("Email: " + email);
    }
}
package com.company;

public class Main {

    public static void main(String[] args) {
        //patient object instantiation
        patient Patient1 = new patient();

        //setting values of data item
        Patient1.setPatientid("001");
        Patient1.setFirstname("Arun");
        Patient1.setLastname("Singh");
        Patient1.setAge(32);
        Patient1.setEmail("[email protected]");

        //display all the items, this method is mentioned in the patient class
        Patient1.display();
    }
}

As no particular language was mentioned, i did it in JAVA.

I also hope it answers your question. Thank you

If you still got any doubt, do post it in comment


Related Solutions

please write this in C # Create a Patient class which has private fields for patientid,...
please write this in C # Create a Patient class which has private fields for patientid, lastname, firstname, age, and email. Create public properties for each of these private fields with get and set methods. The entire lastname must be stored in uppercase. Create a main class which instantiates a patient object and sets values for each data item within the class. Display the data in the object to the console window.
2. Consider the following relations: Doctor(SSN, FirstName, LastName, Specialty,YearsOfExperience, PhoneNum) Patient(SSN, FirstName, LastName, Address, DOB, PrimaryDoctor_SSN)...
2. Consider the following relations: Doctor(SSN, FirstName, LastName, Specialty,YearsOfExperience, PhoneNum) Patient(SSN, FirstName, LastName, Address, DOB, PrimaryDoctor_SSN) Medicine(TradeName, UnitPrice, GenericFlag) Prescription(Prescription Id, Date, Doctor_SSN, Patient_SSN) Prescription_Medicine(Prescription Id, TradeName, NumOfUnits) Note: The Medicine relation has attributes, trade name, unit price, and whether or not the medicine is generic (True or False). a. Determine the functional dependencies that exist in each table given above.
***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The...
***IN JAVA*** Write a program contained a class Student which has firstName, lastName, mark, grade. The program should allow creation an array of object instances to assign firstName, lastName and mark from input user and perform and assign grade based on mark’s criteria displayed below. MARKS INTERVAL 95 - 100 90 - <95 85 - <90 80 - <85 75 - <80 70 - <75 65 - <70 60 - <65 0 - <60 LETTER GRADE A+ A B+ B...
This lab uses a Student class with the following fields: private final String firstName; private final...
This lab uses a Student class with the following fields: private final String firstName; private final String lastName; private final String major; private final int zipcode; private final String studentID; private final double gpa; A TestData class has been provided that contains a createStudents() method that returns an array of populated Student objects. Assignmen The Main method prints the list of Students sorted by last name. It uses the Arrays.sort() method and an anonymous Comparator object to sort the array...
Java programming. ** Create Account class include: 1/ private long   accountNumber; 2/ private String firstName; 3/...
Java programming. ** Create Account class include: 1/ private long   accountNumber; 2/ private String firstName; 3/ private String lastName; 4/ private double balance; 5/ public Account(long accountNumber, String firstName, String lastName, double balance); 6/ get/set methods for all attributes. 7/ public boolean deposit(double amount);   • deposit only if amount is greater than 10 but   less than 200, add the deposit   amount   to the   currentbalance. • if deposit is   successful return true,   otherwise return false; 8/ public boolean withdrawal(double amount); •...
C++ Classes & Objects Create a class named Student that has three private member: string firstName...
C++ Classes & Objects Create a class named Student that has three private member: string firstName string lastName int studentID Write the required mutator and accessor methods/functions (get/set methods) to display or modify the objects. In the 'main' function do the following (1) Create a student object "student1". (2) Use set methods to assign StudentID: 6337130 firstName: Sandy lastName: Santos (3) Display the students detail using get functions in standard output using cout: Sandy Santos 6337130
Problem 6: (20 pts) Create two subclasses called outpatient and inpatient which inherit from the patient...
Problem 6: (20 pts) Create two subclasses called outpatient and inpatient which inherit from the patient base class. The outpatient class has an additional data field called doctorOfficeID and the inpatient class has an additional data item called hospitalID. Write a main method that creates inpatient and outpatient objects. Sets data for these objects and display the data.
Create a class named “Car” which has the following fields. The fields correspond to the columns...
Create a class named “Car” which has the following fields. The fields correspond to the columns in the text file except the last one. i. Vehicle_Name : String ii. Engine_Number : String iii. Vehicle_Price : double iv. Profit : double v. Total_Price : double (Total_Price = Vehicle_Price + Vehicle_Price* Profit/100) 2. Write a Java program to read the content of the text file. Each row has the attributes of one Car Object (except Total_Price). 3. After reading the instances of...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields:...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields: position x, position y, and the direction (east, south, west, and north). Assume that positive x points to the east and positive y points to the south, and initially x = 0, y = 0, direction = "east". Create a no-arg constructor and another constructor which sets the three data fields. Create the accessors and mutators for the three data fields. Create a method...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields:...
[20 marks] (TestRobot.java) Design a class named Robot. The Robot class has three private data fields: position x, position y, and the direction (east, south, west, and north). Assume that positive x points to the east and positive y points to the south, and initially x = 0, y = 0, direction = "east". Create a no-arg constructor and another constructor which sets the three data fields. Create the accessors and mutators for the three data fields. Create a method...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT