Question

In: Computer Science

SOLUTION IN JAVA LANGUANGE NEEDED. JAVA LANGUAGE QUESTION. NOTE - Submission in parts. Parts required -...

SOLUTION IN JAVA LANGUANGE NEEDED. JAVA LANGUAGE QUESTION.

NOTE - Submission in parts. Parts required - Dog Class Code, Dog Manager Class Code and the main code. Please differentiate all three in the answer.

This Assignment is designed to take you through the process of creating basic classes, aggregation and manipulating arrays of objects.

Scenario:

A dog shelter would like a simple system to keep track of all the dogs that pass through the facility.

The system must record for each dog:

dogId (int) - must be unique

name (string)

age (double) - cannot be less than 0 or more than 25

breed (string)

sex (char) – m for male, f for female

foundHome (bool)    - true means the dogs has been places in a home false otherwise.

You must create an object oriented solution with a text based menu as summarized on the next page. The system must check that valid data is entered. For example, the menu has four items so only 1 to 5 must be allowed as input from the menu.

Summary of Operations

System Menu:

Add dog

View all dogs

View all available dogs

View dog

Update dog home status

exit

Overview:

Add Dog:

When a dog is added to the system, you must check that the dogId is not already used in the system. All new dogs have no home as yet (foundHome = false).

View all Dogs:

This menu option shows all dogs in the system. This includes dogs that have a home and those that do not.

View all available dogs:

Shows all dogs in the system, that have no homes as yet.

View dog:

Asks the user for a dogId and then displays the dog information if found and “There is no dog with that id..” if it is not found.

Update dog home status:

Asks the user for a dogId. If a dog with that id is found, the “foundHome” status is changed to true and the dog information is to be displayed. If the dog is not found the message “There is no dog with that id..” should be displayed.

Solutions

Expert Solution

import java.util.*;
class Dog
{
int dogId;
String name;
double age;
String breed;
char sex;
boolean foundHome=false;
public Dog(int id,String n,double age,String breed,char s)
{
this.dogId=id;
this.name=n;
this.age=age;
this.breed=breed;
this.sex=s;
}
}
class DogManager
{
  
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
while(true)
{
  
           System.out.println("System Menu:\n1.Add dog\n2.View all dogs\n3.View all available dogs\n4.View dog\n5.Update dog home status\nother:exit");
           System.out.println("Enter the operation number:");
int input =sc.nextInt();
int id_arr[]=new int[10];
           int k=0;
           Dog d[]=new Dog[10];
int id;
String name;
String breed;
char sex;
double age;
  
switch(input)
{
case 1: System.out.println("Enter Dog Details");
id=sc.nextInt();
name=sc.next();
age=sc.nextDouble();
breed=sc.next();
sex=sc.next().charAt(0);
if(age<=0 && age>25)
{
System.out.println("age should between 1 to 25");
break;
}
int count=0;
                       if(id_arr.length>0){
                       for(int i=0;i<id_arr.length;i++)
                       {
                           if(id_arr[i]==id)
                           {
                               count++;
                           }
                       }
                       }
                       System.out.println("count="+count);
                       if(count==0)
                       {
                           id_arr[k]=id;
                           k++;
                           d[k]=new Dog(id,name,age,breed,sex);
                           Dog p=d[k];
                           System.out.println(p.dogId+" "+p.name);
                          
                       }
                       else
                       {
System.out.println("Dog Id already present");
}
break;
case 2:
System.out.println("DOGID NAME AGE BREED SEX HOME_STATUS");
                       System.out.println(k);
for(int i=0;i<=k;i++)
{
Dog e=d[i];
System.out.println(e.dogId+" "+e.name+" "+e.age+" "+e.breed+" "+e.sex+" "+e.foundHome);
}
break;
case 3:
System.out.println("Dogs without home in the system \n DOGID NAME AGE BREED SEX ");
for(int i=0;i<=k;i++)
{
Dog e=d[i];
if(e.foundHome==false)
{
System.out.println(e.dogId+" "+e.name+" "+e.age+" "+e.breed+" "+e.sex);
}
}
break;
               case 4:System.out.println("Enter a dog id");
int d1=sc.nextInt();
for(int i=0;i<=k;i++)
                       {
                           Dog y=d[i];
                           if(y.dogId==d1)
                           {
                               System.out.println(y.dogId+" "+y.name+" "+y.age+" "+y.breed+" "+y.sex);
                               break;
                              
                           }
                       }
                       System.out.println("There is no dog with that id..");
break;
case 5:System.out.println("Enter a dog id");
int d_id=sc.nextInt();
for(int i=0;i<=k;i++)
                       {
                           Dog y=d[i];
                           if(y.dogId==d_id)
                           {
                               y.foundHome=true;
                               break;
                              
                           }
                       }
                       System.out.println("There is no dog with that id..");
                      
                       break;
  
default: System.out.println("Invalid Input...Please provide input between 1 to 5");
               return;
              

}
}
}
}


Related Solutions

THE QUESTION IS OF JAVA LANGUAGE. ANSWER IS REQUIRED IN THREE PARTS (THREE JAVA FILES). PLEASE...
THE QUESTION IS OF JAVA LANGUAGE. ANSWER IS REQUIRED IN THREE PARTS (THREE JAVA FILES). PLEASE DIFFERENTIATE FILES SO I CAN UNDERSTAND BETTER. NOTE - Submission in parts. Parts required - Dog Class Code, Dog Manager Class Code and the main code. Please differentiate all three in the answer. This Assignment is designed to take you through the process of creating basic classes, aggregation and manipulating arrays of objects. Scenario: A dog shelter would like a simple system to keep...
NOTE - Submission in parts. Parts required - Dog Class Code, Dog Manager Class Code and...
NOTE - Submission in parts. Parts required - Dog Class Code, Dog Manager Class Code and the main code. Please differentiate all three in the answer. This Assignment is designed to take you through the process of creating basic classes, aggregation and manipulating arrays of objects. Scenario: A dog shelter would like a simple system to keep track of all the dogs that pass through the facility. The system must record for each dog: dogId (int) - must be unique...
This project will be submitted in 3 parts. The submission dates and required parts to be...
This project will be submitted in 3 parts. The submission dates and required parts to be completed for each submission are:    Submission 1 - due Monday September 10 before 5pm - You must submit your completed July Journal entries, the Worksheet complete through the Trial Balance, and the worksheet formulas tab complete through the Trial Balance. Your file must be named correctly - "Your name (first and last) Project 1 part 1. Failure to name your file correctly will result...
1. For all parts of this question, working is required, including combinatoric/factorial notation as needed as...
1. For all parts of this question, working is required, including combinatoric/factorial notation as needed as well as final answers. a) (*) A gym has the following group fitness sessions:  Zoomba  Body conditioning  Weight lifting  Boxing  Yoga A member can attend one session at most once a day (i.e., once a member has attended Zoomba classes, s/he cannot attend it again that day). The duration of sessions is also unimportant, however, for example, doing Zoomba...
1.24 Note this is a computational question. Note there are two parts in the question. Clearly...
1.24 Note this is a computational question. Note there are two parts in the question. Clearly type out your answers to each subpart of the question. Show your steps. Hong Kong Telecom asked you to assess its internal control system. After careful review, you believed that Hong Kong Telecom has serious flaws in their internal control system. You estimated that the impact associated with this problem is $20 million and that the likelihood is currently 9%. Three procedures can be...
The code is needed in Java. There are many ways to design a solution to this...
The code is needed in Java. There are many ways to design a solution to this problem but you are evaluated on meeting the specific specifications as given in this quiz. Use proper statement indentation and meaningful variable names in the code. (3 points) Place a multi-line comment (not multiple single line comments) giving a description of what this application does before the class header. Include your name and the date with the description. (2 points) Output spacing, formatting, and...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes...
JAVA LANGUAGE Required Tasks: In Eclipse, create a Java Project as CS-176L-Assign5. Create 3 Java Classes each in its own file Student.java, StudentList.java, and Assign5Test.java. Copy your code from Assignment 4 into the Student.java and StudentList.java Classes. Assign5Test.java should contain the main method. Modify StudentList.java to use an ArrayList instead of an array. You can find the basics of ArrayList here: https://www.w3schools.com/java/java_arraylist.asp In StudentList.java, create two new public methods: The addStudent method should have one parameter of type Student and...
Show some examples of a few Parameters and Objects problems in java language and the solution...
Show some examples of a few Parameters and Objects problems in java language and the solution code. Need more practice as a new learner
Complete all parts of this java program. Use Homework2Driver.java below for testing. /* Note: Do not...
Complete all parts of this java program. Use Homework2Driver.java below for testing. /* Note: Do not add any additional methods, attributes. Do not modify the given part of the program. Run your program against the provided Homework2Driver.java for requirements. */ public class Node<T> { private T info; private Node nextLink; public Node(T info) { } public void setInfo(T info) { } public void setNextLink(Node nextNode) { } public T getInfo() { } public Node getNextLink() { } } /* Note:...
Language for this question is Java write the code for the given assignment Given an n...
Language for this question is Java write the code for the given assignment Given an n x n matrix, where every row and column is sorted in non-decreasing order. Print all elements of matrix in sorted order.Input: The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the matrix. Then the next line contains the n x n elements...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT