Microsoft Word - Assign1_2021.docx University of Newcastle School of Electrical Engineering and Computing SENG1110/6110 Programming Assignment 1 – Semester 1, 2021 Due: By electronic submission...

1 answer below »
Looking for a mark of 90 percent. Thanks


Microsoft Word - Assign1_2021.docx University of Newcastle School of Electrical Engineering and Computing SENG1110/6110 Programming Assignment 1 – Semester 1, 2021 Due: By electronic submission (Blackboard) by 11:59pm on Fri, 30/04. VET CLINIC MANAGMENT Introduction The objective of this assignment is to implement an object-oriented program using Java, to manage doctors and pets in a vet clinic. Assignment 2 will be an extension of this assignment. SENG1110 students - This assignment can be completed in pairs. SENG6110 students - This assignment must be completed individually. Before you start Carefully read the specification below. Make sure you have all the information necessary to start writing the program. If you are uncertain of something, do not make assumptions. Post your questions to the discussion board forum named "assignment 1" and check it regularly. Try to start the assignment as soon as possible. There is a document “HelpToStartAssign1” and some Java files on Blackboard, which you can use as a starting point. Specification The program will keep track of up to 2 doctors, and up to 4 pets. When run, the program will display a menu of actions to the user, including one that exits the program. Until the user chooses to exit, the menu is displayed again after each action is completed. The program must have the following functionalities: 1 The user may enter a new doctor into the vet clinic. The user will input the name and specialisation. If a doctor with the same name already exists, or the specialisation is invalid, or the doctor limit has been reached, the program should output an error message. 2 The user may enter a new pet into the vet clinic. The user will input the name, type, size, weight, and age. If a pet with the same name already exists, or an invalid value is given, or the pet limit has been reached, the program should output an error message. 3 The user may delete a doctor from the vet clinic. The user will input the name of the doctor. If the doctor does not exist, the program should output an error message. Before deletion, all pets that are assigned to the specified doctor should have their 'doctor' instance variable updated to "No doctor assigned". 4 The user may delete a pet from the vet clinic. The user will input the name of the pet. If the pet does not exist, the program should output an error message. 5 The user may request a list of doctors in the vet clinic with all the information of each doctor. Normally, one line should be output for each doctor, with the form: Doctor : specialist. If there are no doctors, the program should output the message "No doctors". 6 The user may request a list of pets in the vet clinic with all the information of each pet. Normally, one line should be output for each pet, with the form: Pet : weighing kg at years old (). If there are no pets, the program should output the message "No pets". 7 The user may request a list of pets assigned to a specific doctor. The user will input the name of the doctor. Normally, one line should be output for each pet, similarly to above. If there are no doctors, the program should output "No doctors". If the named doctor does not exist, the program should output "No doctor with that name". Otherwise, if the doctor has no assigned pets, the program should output "No assigned pets". 8 The user may assign a doctor to a pet. The user will input the name of the pet and the name of the doctor. If the pet or doctor do not exist, or the pet is already assigned to that doctor, or the doctor does not have the right specialisation, the program will output an error message. If the pet is already assigned to another doctor, the program should ask the user to confirm that they would like to change the assigned doctor. 9 The user may analyse a pet. The user will input the name of the pet and the program will output an indication of whether the pet is overweight. A cat is considered overweight if it is: • Small with weight greater than 4kg • Medium with weight greater than 6kg • Large with weight greater than 8kg A dog is considered overweight if it is: • Small with weight greater than 6kg • Medium with weight greater than 9kg • Large with weight greater than 12kg If the pet does not exist, the program will output an error message. Doctor and pet names should be converted to lowercase after input. For example, if the user inputs "Benny", the program should convert it to "benny". Program Requirements: Your program should consist of three classes, with these names and instance variables: • Doctor – stores the following details about a doctor. o name – String – the name of the doctor. Should not contain spaces. o specialisation – String – the specialisation of the doctor. Must be "dog" or "cat". • Pet – stores the following details about a pet. o name – String – the name of the pet. Should not contain spaces. o type – String – the type of the pet. Must be "cat" or "dog". o size – String – the size of the pet. Must be "small", "medium" or "large". o weight – double – the weight of the pet. Must be positive. o age – int – the age of the pet. Must be positive. o doctor – String – the doctor of the pet. Should initially be "no doctor assigned". • Clinic – provides information for all doctors and pets in the clinic. o doctor1, doctor2 – Doctor – up to two doctors. o pet1, pet2, pet3, pet4 – Pet – up to four pets. All instance variables of your classes need to be private (this is imposed so that you apply the principles of encapsulation). Your classes will need methods to provide the required functionalities. The only class which should have a main method is Clinic.java, which should create an instance of the class Clinic, and call a method run(), which will display the menu to the user. This class will be the only one that takes input from and sends output to the user. It may do so using either TIO or GUI methods (your choice). A template is shown below. public class Clinic { private void run(){ //... } public static void main(String[] args){ Clinic c = new Clinic(); c.run(); } } You must not use arrays in this assignment. Marks will be awarded for layout (including visual aspects (variable names, indentation) and structural aspects (variable scope, method usage)), documentation (comments), and the submission's ability to perform as specified. A more detailed marking schema is available on Blackboard. What to submit You should submit only the three .java files (Doctor.java, Pet.java, Clinic.java), in a compressed .zip file, via the "Assignment 1" link on Blackboard. Do not include .class files in your submission. Add your student name(s) on the top of each Java file submitted. If you are completing the assignment as a group (only SENG1110 students), add both names in each Java file AND submit 2 assignment cover sheets. Extra Work for SENG6110 students You need to provide a UML class diagram of your program. Extra material, including lecture slides and a video are available in Blackboard. Late Penalty and adverse circumstances Note that your mark will be reduced by 10% for each day (or part day) that the assignment is late. This applies equally to week and weekend days. You are entitled to apply for special consideration if adverse circumstances have had an impact on your performance in an assessment item. This includes applying for an extension of time to complete an assessment item. See https://www.newcastle.edu.au/current-students/learning/assessments-and-exams/adverse- circumstances for more details. Prof Regina Berretta - 2021 Microsoft Word - Assign1_2021MarkingSchema (edited).docx SENG1110/6110 - semester 1 - 2021 - Assignment 1 Marking Schema ID: Name: Marker: Incorrect file name /-2 each Pet Class Class not submitted /-20 each Instance variables /private /2 Compiles /-3 each Methods /6 Run /-3 each General class design/organisation /4 Functionality Clinic Class Add doctor/check /4 Instance variables /private /2 Add pet/check /5 Methods
Answered Same DayApr 29, 2021

Answer To: Microsoft Word - Assign1_2021.docx University of Newcastle School of Electrical Engineering and...

Kshitij answered on Apr 30 2021
145 Votes
Doctor/Clinic.java
Doctor/Clinic.java
/*   Created by IntelliJ IDEA.
 *   Author: Kshitij Varshney (kshitijvarshne1)
 *   Date: 29-Apr-21
 *   Time: 6:18 PM
 *   File: Clinic.java
 */
package April.api29_21;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
public class Clinic {
    List doctorList = new ArrayList<>();
    List petList = new ArrayList<>();
    public static void main(String[] args) {
        Clinic c = new Clinic();
        c.run();

    }
    private void run() {
        while (true) {
            showOptions();
            int k = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter the option menu", "Input Window", JOptionPane.PLAIN_MESSAGE));
            switch (k) {
                case 1 -> {
                    JTextField name = new JTextField();
                    JTextField specialisation = new JTextField();
                    Object[] input = {
                            "Enter doctor name:", name,
                            "Enter doctor specialisation", specialisation
                    };
                    JOptionPane.showConfirmDialog(null, input, "Input ", JOptionPane.OK_CANCEL_OPTION);
                    boolean result = addDoctor(name.getText(), specialisation.getText());
                    if (result) {
                        JOptionPane.showMessageDialog(null, "New Doctor is inserted", "Message", JOptionPane.PLAIN_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null, "New Doctor is not inserted", "Message", JOptionPane.ERROR_MESSAGE);
                    }
                }
                case 2 -> {
                    JTextField petName = new JTextField();
                    JTextField type = new JTextField();
                    JTextField size = new JTextField();
                    JTextField weight = new JTextField();
                    JTextField age = new JTextField();
                    JTextField doctorName = new JTextField();
                    Object[] input2 = {
                            "Enter pet name:", petName,
                            "Enter pet type", type,
                            "Enter pet size:", size,
                            "Enter pet weight", weight,
                            "Enter pet age:", age,
                            "Enter doctor name :", doctorName
                    };
                    JOptionPane.showConfirmDialog(null, input2, "Input ", JOptionPane.OK_CANCEL_OPTION);
                    boolean result2 = addPet(petName.getText(), type.getText(), size.getText(), Integer.parseInt(weight.getText()), Integer.parseInt(age.getText()), doctorName.getText());
                    if (result2) {
                        JOptionPane.showMessageDialog(null, "New pet is inserted", "Message", JOptionPane.PLAIN_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null, "New pet is not inserted", "Message", JOptionPane.ERROR_MESSAGE);
                    }
                }
                case 3 -> {
                    String name3 = JOptionPane.showInputDialog(null, "Enter the doctor name", "Input", JOptionPane.PLAIN_MESSAGE);
                    boolean result3 = deleteDoctor(name3);
                    if (result3) {
                        JOptionPane.showMessageDialog(null, " Doctor is deleted", "Message", JOptionPane.PLAIN_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null, " Doctor is not deleted", "Message", JOptionPane.ERROR_MESSAGE);
                    }
                }
                case 4 -> {
                    String name4 = JOptionPane.showInputDialog(null, "Enter the pet name", "Input", JOptionPane.PLAIN_MESSAGE);
                    boolean result4 = deletePet(name4);
                    if (result4) {
                        JOptionPane.showMessageDialog(null, " pet is deleted", "Message", JOptionPane.PLAIN_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null, " pet is not deleted", "Message", JOptionPane.ERROR_MESSAGE);
                    }
                }
                case 5 -> showListOfDoctors();
                case 6 -> showListOfPets();
                case 7 -> {
                    String name5 = JOptionPane.showInputDialog(null, "Enter the doctor name", "Input", JOptionPane.PLAIN_MESSAGE);
                    listOfPetsAssignedToASpecificDoctor(name5);
                }
                case 8 -> {
                    JTextField doctor = new JTextField();
                    JTextField pet = new JTextField();
                    Object[] input3 = {
                            "Enter doctor name:", doctor,
                            "Enter pet name: ", pet
                    };
                    JOptionPane.showConfirmDialog(null, input3, "Input ", JOptionPane.OK_CANCEL_OPTION);
                    assignedADoctorToPet(doctor.getText(), pet.ge...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here