Okay so i thought i would get a jumpstart on my homework for my CPS181 (Data structures) course. I got an assignment that contains 4 problems each having to do with the one before (like 2 continues on from 1).
-------------------------------------------------------------------------------------------------------------------------------------
Directions: First, implement a class named Patient. This class will represent one patient, and must have the following data attributes and methods:
1. name: a String
2. age: an int
3. gender: a char
4. priority: an int
5. a default constructor
6. a parameterized constructor to set the attributes above
7. a toString method to print out the data attributes above.
-------------------------------------------------------------------------------------------------------------------------------------
Okay so i understand on making the program (sort of). Basically my questions is: How do i run this program but still allow another class to use everything inside?
Here is my code (which i cant execute bc there is no main function...due to my thought of using this class for the next one)
Code :public class Patient { // Default constructor private String name; private int age; private char gender; private int priority; private Patient next; public Patient(String name, int age, char gender, int priority) { // Parameterized constructor super(); this.name = "Patrick Kinnicutt"; this.age = 20; this.gender = 'M'; this.priority = 0; next= null; } public String toString() { String msg = String.format("Patient: " + name + "\n Age: " + age + "\n Gender: " + gender + "\n Priority: " + priority); return msg; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public char getGender() { return gender; } public void setGender(char gender) { this.gender = gender; } public int getPriority() { return priority; } public void setPriority(int priority) { this.priority = priority; } public Patient getNext() { return next; } public void setNext(Patient next) { this.next = next; } }
Thanks for the help :D

