Design and implement classes with suitable fields

Assignment Help JAVA Programming
Reference no: EM133071679

IMAT5101 Object Oriented Programming - De Montfort University

Question: You are given a scenario for your assignment. This takes the form of a design description and a specification by way of a class diagram. You should gain an understanding of the scenario, implement the class diagram, and produce the functionality listed within the use cases.

You should implement each class to the expected standards as discussed and practiced during the module.

Objectives

The objective of this assessment is for you to demonstrate your ability to design and implement an 00 system consisting of a set of Java classes and a client program. In particular:

1. To design and implement classes with suitable fields, constructors, accessor methods, and modifier methods.

2. To confirm to the standard conventions of Java.

3. To implement classes that are associated by inheritance, delegation, composition, and aggregation.

4. To write a client application that uses your classes to show that they function correctly.

Scenario: Hospital Booking System

When making appointment to visit the hospital, a Patient with Name and patientlD makes an Appointment with a Doctor. The Doctor can either by a ConsultantDoctor or JuniorDoctor. After diagnosis, the Doctor will give the Patient a Prescription with Medication or DiscountedMedication and price of each. The content of Prescription can be sorted in various ways and total cost can be calculated. Medications in a Prescription can be iterated over and tested for equality.

The partial UML class diagram below shows the underlying data model you should use to achieve this scenario:

Class

Comment

Name

Simple name comprising a first name and family name.

Date

Simple date record with day/month/year fields. Validate on update

Patient

A Patient has a name, unique ID, and age.

Patient can be tested for equality by providing an appropriate overridden equals(...) method that assesses the equality of ID field.

Doctor

An abstract class with unique id, Name, and department. It also has an abstract method generateDoctorIDO that generates the doctorID and returns it

Co n sultantDoctor

A Consultant Doctor is a Doctor with specialization and can be a team leader or not.
When generating the doctorlD, it should start with "C", followed by 4-digit random
number (e.g. C1234). You are expected to use the java.util.Random class in doing
this

inniorDoctor

A Junior Doctor is assigned to a single team.

When generating the doctorlD, it should start with "J", followed by 4-digit random number (e.g. J1234). You are expected to use the java.util.Random class in doing this

Medication

A Medication has a name, unique ID, and fixed price (irrespective of quantity). One medication can have different price (e.g. Paracetamol for children is £3.50, but same paracetamol for adults is £3.80).

Medication can be tested for equality by providing an appropriate overridden equals(...) method that assesses the equality of ID field and fixed price.

Additionally, Medication are comparable, so they can be sorted into a natural order. They should firstly be compared by Medication id, if these are the same, then by price.

DiscountedMedicati on

A Discounted Medication is a Medication with a discount rate applied. The discount rate should be between 0 and 1.0, with 0.1 being a 10% discount, 0.2 being a 20% discount, etc.

When retrieving the price of a discount Medication it should return the standard price with any discount applied. A discount amount should always be to 2 decimal place, e.g. a calculated discount of £7.988686 would apply as a discount of £7.99 on the unit.

,appointment

An Appointment is made by a Patient for a specified Date

An Appointment can be tested for equality - an Appointment is equal to another if its associated Patient and Date are the same.

Appointments

Appointments can be filtered by appointmentlD to find a specific Appointment.

Appointments can be filtered by patientID to find all appointments made by a Patient.

One can get the list of completed and pending Appointments Appointments can be sorted naturally or using custom comparator

Prescription

A Prescription is for an appointment and has a unique id. It consists of a list of medications, and the doctor that made the prescription. It has a set of methods to add/remove and retrieve a medication so that it can be modified or printed on a receipt, for example. The total cost of the Prescription is given by the getCostO method. An Prescription can be checked for medication by using medicationid.

A Prescription should also allow its Medications to be sorted into their natural order via a sortMedicationO method. It should provide an additional overloaded method sortMedication(Comparator<Medication>) that accepts a custom comparator and applies this to the list of Medications.

The       Prescription requires  two      further        methods:    containsMedication and

removeMedication, as shown in the UML diagram, that will make use of an equality test.

A Prescription should also provide an iterator over its Medications.

The table below gives further guidance on the implementation of each class:

Prescription Test

UC1: A test program that creates 2 instances of Prescription, populates them with several Medication (for both Medication and discounted medication), and uses a for-each loop to produce a formatted listing of the medications with their price, the number of items in the prescription and the overall total price.

Note: You can either use a data file to dynamically read Medication/Appointments or hard-code the Medication/ Appointments instances to add to the Prescription.

UC2: Test each of the sort methods work as expected, as evidenced by appropriate output.

- For the sortMedication(Comparator<Medication>) method, you should pass in a custom comparator that sorts by price (asc) and if these are the same then by Medication name (desc).

UC3: Additionally, test the use of equality by using the contains and remove methods klso, you should use a PrintWriter to produce a receipt for all of the Medicativa and associated details of the Prescription, and output these into a text file Prescription.txt

UC4: Add further code to show how each method of Prescription and Appointments can be used. Add or remove one or more of the Medications in the Prescription, and then re-print the updated Prescription listing.

Use Cases: You should have a test class, with a main method, that should complete the following use cases for the "Prescription System" to show it works as expected. Please clearly highlight where each use cassase is exercised in your test program with comments:

STAGE 2 When prescription is given, reward points may be gained if the patient is a child (under 18 years) or aged (older than 65 years) and prescribed some selected medications. A reward processor holds a collection of each Medication for which points should be awarded, and can process a shopping Prescription to ascertain its contents and apply any necessary awards.

The partial UML class diagram below shows some updates to the underlying data model. Please note: The Patient and Medication classes should remain as before, but should include any additional implementation details as shown in the UML diagram.

The table below gives further guidance:

Class

Comment

Patient

A Patient now has a field to hold their reward points, a means of adding these, and retrieving their current quota of points.

RewardProcessor

A reward processor should store Medication, which can gain rewards for the Patient if they are in their Prescription. A hash set collection should be used for this. The rewardPoints(Prescription) method checks if a rewardable Medication is in the Prescription, and if so adds points to the Prescription's Patient. The number of

points to be added should be the 1 of each Medication. The method should return the total number of reward points that have been awarded to the Patient for this Prescription.

Note: you may need to do some research into how to use a HashSet collection in Java.

Use Cases: Add the following use case at the end of your existing code in your test program - you may need to update other code that has been affected by the additional changes.

Prescription lest

UCS: Create an instance of RewardProcessor, add a selection of Medication to it (but not all the same as those in your Prescription), and then test the rewardPoints method appropriately.

 

 

Attachment:- Object Oriented Programming.rar

Reference no: EM133071679

Questions Cloud

Estimate the current value of the stock : Mohan Gupta is the portfolio manager of an India - based equity fund. He is analyzing the value of Tata Chemicals Ltd. (Bombay Stock Exchange: TATACHEM). Tata C
What are the two major regulatory changes : What are the two major regulatory changes that have affected the financial industry over the last decade? Explain its effects and influence.
Explain the difference in results between the two indices : A. Based on the info in the table, compute 2019 and 2020 values for a price-weighted index and a market-value-weighted index.
What is the total delta : Delta and Gamma with Uniform Distribution Current underlying price at 100, and you expect price at expiration follows uniform distribution with mean absolute de
Design and implement classes with suitable fields : Design and implement classes with suitable fields, constructors, accessor methods, and modifier methods - implement classes that are associated by inheritance
Supply chain management and financial plan : "One of the most important steps in launching a new business venture is fashioning a well-designed, practical, realistic financial plan."
How budget can impact project : Write a summary of how a budget can impact a project that you are working on at home or at work-from managing your personal finances
Limitations of comparable firm method and regression method : 1. Compare the (a) comparable firm and method and (b) regression method in relative valuation.
What does the account balance sheet look like : a. Suppose you want to buy 10,000 shares of MegaWorld Corporation at a price of 4.00 You put up P10,000 and borrow the rest. What does your account balance shee

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a program that converts user input in dollars

Create a program that converts user input in Dollars to Euro, Yen, or Peso.Prompt the user to enter $ amount.

  Develop applications involving complex component technology

Enterprise Programming - Describe elements of a common object oriented programming language suitable for web based application development

  Create program that converts Centigrade to Fahrenheit

CWMD2601 - Scripting for Design Assignment - Functions, DURHAM COLLEGE, Canada. create a JavaScript program that converts Centigrade to Fahrenheit temperatures

  Exploration of the java language and the eclipse environment

Software Development Lifecycle (CS-250) - Southern New Hampshire University - Using the source code given, update the simple list to your top five chosen

  Program to convert fahrenheit to celsius

Layout the planned structure and steps to accomplish the individual programs. Ensure brief, accurate and complete detailed instructions in the form of pseudocode, not code. Construct two brief explanations for the pseudocode. Provide both programs..

  Describe an application that would be a good choice

Describe an application that would be a good choice for using 3D array. Provide the size of the array and the most likely data type. Provide the specific Java

  Write a program displaying a text file

Write a program displaying a text file that is in a text area - The user enters a file name in a text field and clicks the view button; the file is then displayed in the text area. Do not use BufferedInputStream.

  Determine and print the weekly rate.

Write the Java Statements that retrieve the age of the child and the number of days the child will be at the day care center.

  Define a class with properties and methods for a person

Problem Summary Suppose you wanted to modify your Health Assistance Calculator from Java programming assignment 3, to make it more versatile. Define a class with properties and methods for a person.

  Design and implement the class day

Design and implement the class Day that implements the day of the week in a program. The class Day should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type Day: Set the day

  Simulating the behaviour of a train management system

You will develop the component classes of a program for simulating the behaviour of a train management system - You must implement these classes as if other programmers were, at the same time, implementing the code that instantiates them and calls t..

  Prepare a progrma using if else statements

You need to write a program that uses if else statements(No switch) that declares 2 numbers as variables.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd