gpt-4o-2024-08-06· openai
from WildChat-4.8M
public class Main { public static void main(String[] args) { Drug drug = new Drug();…
- User
public class Main { public static void main(String[] args) {
codeDrug drug = new Drug(); System.out.println("Вывод: " + "{" + drug.getName() + ", " + drug.getIll() + ", " + Drug.cost + ", " + Drug.wish + "}"); Patient patient = new Patient(); System.out.println("Вывод: " + "{" + patient.getName() + ", " + patient.getSurname() + ", " + patient.getAge() + ", " + Patient.height + "," + Patient.status + "}"); Shedule shedule = new Shedule(); System.out.println("Вывод: " + "{" + shedule.getDrug() + ", " + shedule.getPatient() + ", " + shedule.getAdress() + ", " + shedule.getTime() + ", " + Shedule.weather + ", " + Shedule.floor + "}"); MedicalPreparation preparation = new MedicalPreparation(drug, patient); System.out.println("Вывод: " + "{" + preparation.getName() + ", " + preparation.getIll() + "," + preparation.typeOfProduct + ", " + MedicalPreparation.weightBottle + ", " + MedicalPreparation.count +"}"); }}public class MedicalPreparation extends Drug { String typeOfProduct = "Таблетка"; private String name; static double weightBottle; static int count;
codestatic { weightBottle = 30.03; count = 25; } { name = "Парацетамол"; } public MedicalPreparation(String name, String ill, String typeOfProduct, double wB, int ct) { super(name, ill, cost, wish); this.typeOfProduct = typeOfProduct; this.name = name; weightBottle = wB; count = ct; } public MedicalPreparation(Drug drug, Patient patient) { } @Override public String getName() { return name; } @Override public void setName(String name) { this.name = name; } MedicalPreparation() { } - Assistant
В приведённом коде объявлены следующие типы полей данных:
-
Примитивные типы данных:
int(например, для полейage,time,count,floor).double(например, для полейcost,height,weightBottle).boolean(например, для поляwish).
-
Ссылочные типы данных:
String(например, для полейname,surname,ill,adress,weather,typeOfProduct).- Классы-объекты (например, для полей
DrugиPatientв классеShedule).
Таким образом, в коде объявлено два типа полей данных: примитивные и ссылочные типы данных. Примитивные поля включают типы
int,double, иboolean, а ссылочные поля включают типаStringи пользовательские классы. -