Computer Science Homework Solutions
Problem
#4128

Do not understand concepts of variables, classes, strings, and especially how to save data for later use when creating a program in java.

The attached file is the assignment I have been given to do. I can understand certain things, which I have attached in another file. But I don't understand some things and think i'm leaving something out, mybe some variables? somehow. As much help as you can give me with how to make the program work, especially the admit button, and hints for using java would be great.
Basically, what do I need to do to make it work?

Attached file(s):
Attachments
SENGASGNMENT2.doc  View File
ASSIGNMENT2.txt  View File

Attachment Content Summary (Note: view attachment at the above link before purchasing. Actual attachment content may vary slightly from that shown below.)

SENGASGNMENT2.doc
Scenario

A hospital has asked you to write a program to keep track of the
patients in its wards. Each ward will have its own copy of the software,
so the program is only required to deal with a single ward. The name of
the driver program should be ProgAsgn2.

Patients

A patient object consists of name, date of birth, date of admission,
treating doctor and diagnosis; for the purposes of this assignment, all
of these can be Strings. (Admission is when a patient is accepted into
the ward and discharge is when the patient is permitted to leave.) Your
program should include a class that models an individual patient. Your
patient model should implement information hiding, allowing access to
instance data only through appropriate accessor and mutator methods.

The Ward

Another class will then establish and work with an array of as many
patient objects as there are beds in the ward (it would make sense to
store this number as a constant). This class will effectively be a model
of the ward. Unoccupied beds will be represented as null. The ward
should also follow information hiding principles.

The GUI

The program should work by way of a GUI that has a title, text fields
for the details of the current patient, five buttons, and a text area
for display of the occupied beds and the patients occupying them. Each
of these is described below.

The title of the GUI should be a suitable one of your own choosing.

At any given time one of the patients will be the ‘current’ patient.
That patient’s details, along with the patient’s bed number, will be
displayed in the GUI’s text fields. Any details displayed in those
fields can be edited, and the changes will be registered when any of the
buttons is pressed. If no beds are occupied, there will be no current
patient, and the text fields should be blank.

At the same time, the details of all occupied beds and their patients
will be displayed in the text area. If two beds are occupied, two lines
of data will appear in the text area; if 17 beds are occupied, 17 lines
of data will appear in that area.

The New patient button should clear the text fields so that the details
of a new patient can be entered, except that if all beds are occupied,
the user should be informed that no further admissions are possible.
Once the New Patient button has been selected and the new patient data
entered, it is expected that the next button selected will be Admit
Patient, otherwise a message box should be displayed saying that the
information entered has been lost.

The Admit Patient button should use the contents of the text fields to
create a new patient in the indicated bed, except that if the indicated
bed number represents an occupied bed, the user should be invited to
enter the number of an unoccupied bed and try again. A successful
admission should be indicated with a message box.

The Discharge Patient button should generate a suitable message and
remove the current patient from the display. The next occupied bed will
then become the current one.

The Next Patient and Previous Patient buttons should move to the next
occupied bed and the previous occupied bed respectively, making the
occupant of that bed the current patient and displaying that patient’s
details in the text fields. From the point of view of these buttons, the
ward is a ‘circular’ arrangement; in a 12-bed ward, the ‘Next’
bed to bed 12 is bed 1 and the ‘Previous’ bed to bed 1 is bed 12.
Because the user can edit the details of the current patient, these
should be updated from the text fields before moving on.
ASSIGNMENT2.txt
import javax.swing.*;
import BreezySwing.*;

public class ProgAsgn2 extends GBFrame{

//Window objects

Jlabel nameLabel = addLabel("Name:",3,3,1,1);
JLabel birthLabel = addLabel("Date of Birth:",4,3,1,1);
JLabel admitLabel = addLabel("Admission Date:",5,3,1,1);
JLabel doctorLabel = addLabel("Treating Doctor:",6,3,1,1);
JLabel diagnosisLabel = addLabel("Diagnosis:",8,3,1,1);
JLabel bedLabel = addLabel("Bed Number:",1,3,1,1);
JLabel bedsInWardLabel = addLabel("Number of Beds In Ward:",17,1,2,1);

JButton newButton = addButton("New Patient",3,5,1,1);
JButton admitButton = addButton("Admit Patient",6,5,1,1);
JButton dischargeButton = addButton("Discharge Patient",9,5,1,1);
JButton previousButton = addButton("<< JButton nextButton = addButton("Next>>>",15,5,1,1);

JTextField nameTextField = addTextField(" ",3,4,1,1);
JTextField birthTextField = addTextField(" ",4,4,1,1);
JTextField admitTextField = addTextField(" ",5,4,1,1);
JTextField doctorTextField = addTextField(" ",6,4,1,1);

JTextArea diagnosisTextArea = addTextArea(" ",9,3,2,7);
JTextArea bedsTextArea = addTextArea(" ",1,1,2,16);

IntegerField bedNumberIntegerField = addIntegerField(" ",1,4,1,1);
IntegerField bedsInWardIntegerField = addIntegerField(0,17,2,1,1);

//Other instance variables
int bed; //bed number
int patient; //patient number
int bedsInWard; //number of beds in ward

private int indexSelectedPatient;
private int patientCount;

//Constructor

public ProgAsgn2(){
setTitle("Patient Database--Version 1");

indexSelectedPatient=1;
patientCount=0;

displayCurrentPatient();
}

//buttonClicked method

public void buttonClicked(JButton buttonObj){
if(buttonObj == newButton){
newPatient();
}else{
if(buttonObj == admitButton){
admitPatient();
}else{
if(buttonObj == dischargeButton){
dischargePatient();
}else{
if(buttonObj == previousButton){
displayPreviousPatient();
}else{
if(buttonObj == nextButton){
displayNextPatient();
}

//private methods

private void newPatient(){
int bedsInWard=bedsInWardIntegerField.getNumber();
if(int bedsInWard == 0){
messageBox("Please enter number of beds in ward");
return;
}else{
if(!int bedsInWard.isValid()){
messageBox("Sorry:The number of beds must be an integer.";
return;
}else{
if(int bedsInWard.isValid()){
resetAllFields();

if buttonObj == admitButton){
admitPatient();
}else{
messageBox("Admission not complete.Details will be lost unless admitted.";
return;
}


private void resetAllFields(){
nameTextField.setText(" ");
birthTextField.setText(" ");
admitTextField.setText(" ");
doctorTextField.setText(" ");
diagnosisTextArea.setText(" ");
bedsInWardIntegerField.setNumber(" ");
}


Solution
What is this?
By OTA - Overall OTA Rating
Departed OTA
Purchase Cost Now
$2.19 CAD (was ~$3.99)
Included in Download
  • Plain text response
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Automata - Let  be a 3cnf-formula. An  assignment to the variables of  is one where each clause contains two literals with unequal truth values. In other words an  -assignment s ...
  • Automata and Computability - Let G be CFG in Chomsky normal form that contains b variables. Show that, if G generates some string using a derivation with more than b steps, L (G) is infinite.
  • Create an ERD - Huffman Fleet Truck - The following assignment is based upon Service Request SR-ht-003, "Develop a Design for a Fleet Truck Maintenance Database." You only need to describe assumptions, changes, and additions you make ...
  • Global variables - Hello it is said that the use of global variables should be limited unless it's absolutely necessary. What's your thoughts on this? and why?
  • Break Down on querying and scripting - Use SQL Management Studio to create a database called ITD640_P1.MDF. Be sure to store the database in a location that you will remember. Add the tables and data shown below to the database. Use the ap ...
Browse