Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java using netbeans please provide student, cat, dog and petshelter classes thank you package csc170labs; /* * Student.java * CSC 170 Example code */ /**

java using netbeans please provide student, cat, dog and petshelter classes thank you image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
package csc170labs; /* * Student.java * CSC 170 Example code */ /** * Represents a Student. * Includes name, age along with a GPA. * @author CSC170LAB */ public class Student{ //instance variables - data private String name; private int age; private double gpa; //setters and getters /** * Sets the name of this Student. * @param name the name for this Student. */ public void setName(String name){ this.name = name; } /** * Returns the name of this Student. * @return the name of this Student. */ public String getName(){ return this.name; } /** * Sets the age of this Student. * @param age the age for this Student. */ public void setAge(int age){ this.age = age; } /** * Returns the age of this Student. * @return the age of this Student. */ public int getAge(){ return this.age; } /** * Sets the grade point average of this Student. * @param gpa the grade point average for this Student. */ public void setGpa(double gpa){ this.gpa = gpa; } /** * Returns the grade point average of this Student. * @return the grade point average of this Student. */ public double getGpa(){ return this.gpa; } /** * Display the student name, age and grade point average. * @return nothing. */ public void displayInfo(){ System.out.println("Name: " + this.name); System.out.println("Age: " + this.age); System.out.println("GPA: " + this.gpa); } }
The goal of this lab is to learn the followings: Get familiar with the ArrayLists and the static variables and method. Phase 1 - Modifying the Student class Add a new private static variable called "nextStudentID and initialize it to 1000. Add the following private instance ArrayLists. ArrayList name Data type currentCourseList String completed CourseList String Modify the constructor defined in BigLab 3 as follows: Modify the assignment to the studentID instance variable: Assign the "AUG" + nextStudents to studenti Increase the nextStudentiD by one. Initialize both ArrayLists within the constructor defined in BigLab3. Generate getter methods for both ArrayLists. 1 Add the following methods. addNewCurrentCourse(String courselD): Add a new course to the currentCourseList dropCurrentCourse(String courselD): Remove a course from the currentCourseList if it exists in the list and display "Drop Successfully": Otherwise, display an error message "No such course exists". [Hint: Use contains() ArrayList method to check whether the element exists or not. Use indexOf() method to get the index of an existing element.) displayActiveCourses(); Display the courses in currentCourseList. semesterComplete(): Add all the courses from currentCourseList to the completed CourseList. Set the completed CreditHours instance variable value to (the number of courses in completed CourseList. 4). displayCompleted Courses(): Display the courses in completed CourseList. Add or modify the JavaDoc comments in Student class based on the newly added/modified methods. Phase 2 - Modifying the Cat class and Dog class. In Cat class Add a new private static variable called "nextCati and initialize it to 0. Add a new private instance variable called catid Modify the constructor defined in Biglab 3. Within the constructor, assign a value to catiD as follows. Assign the "Cat + nextCatID Increase the nextCatID by one. - Add getter and setter methods for catid 2 In Dog class, Add a new private static variable called "nextDogID" and initialize it to 0. Add a new private instance variable called dogID. Modify the constructor defined in BigLab 3. Within the constructor, assign a value to DogID as follows. Assign the "Dog* + nextDogid Increase the nextDogin by one. - Add getter and setter methods for dogid. Add/modify the JavaDoc comments in the Cat and Dog classes. Phase 3 - Add the new class PetShelter to your project. Add another.java file called PetShelter into the same folder CSC170Labs. . Add the following private instance variables/ArrayLists. Variable name Data type shelterName String shelterID String location String currentCatList ArrayList of Cat class objects currentDogList ArrayList of Dog class objects Generate setters and getters for the following instance variables. shelterName shelter D location Generate getters for the ArrayLists. currentCatList currentDogList Add the following private static integer variable. Variable name Data type Initial value nextShelter D int 0 3 Add a new constructor public PetShelter (String name, String location): Takes the name and the location as parameters and sets the instance variables. Next, assign a value to shelteriD as follows. Assign the "PetShelter + nextShelterID Increase the nextShelter D by one. Initialize the currentCatList and currentDogList ArrayLists Add the following methods. addCatCat c) - This method takes a Cat class object and adds that to the currentCatList ArrayList. addDog(Dog d) - This method takes a Dog class object and adds that to the currentDogList ArrayList. displayCatList() - This method displays the list of names of the Cats live in the shelter. displayDogList() - This method display the list of names of the Dogs live in the shelter. who Needs MoreHelp() - This method display messages based on the number of Cats and Dogs in the shelter. If there are no Cats > "No cats in the shelter" If there are no Dogs -> No dogs in the shelter If there are more Cats than Dogs -> "Cats need more help! If there are more Dogs than Cats > Dogs need more help!" If the number of Dogs and cats are the same (and it is not zero) -> "Both cats and dogs need help This method may display more than one message at a time. adoptCat(int age) - This method removes the first Cat older than the given age from the list. Follow these steps: 1. If there is a Cat older than the given age, display its information and then remove it 2. Otherwise, display the message "All the Cats are younger than years! adoptDog(String color) - This method removes the first Dog with the given color from the list. Follow these steps: 1. If there is a Dog with the given color, display its information and then remove it. 2. Otherwise, display the message "No Shelter ID: Location: Current number of cats: Current number of dogs: Add JavaDoc comments in PetSelter class to describe the class, constructor, and all the methods (getters, setters, and instance methods). Phase 4- Modifying the main method in the MainDriver class Your existing code in the main method can be either deleted (if you have submitted all the previous labs) or commented. Student class: a. Create a Student class object using the modified constructor defined in Phase 1. You may pass constant string values for the name, email, major, degreeType and the currentYear. b. Display the student information of this student C. Take current courses from the user until the user enters - 1 and add them to the student's current courses list. d. Display active courses. e. Take another course from the user and drop that course from the current course list. f. Call the semester Complete method and next display the list of completed courses 5 PetShelter class a. Create a PetSheter class object using the constructor defined in Phase 3. You may pass constant string values for the shelter name and the location. [This part of the program is similar to the BigLab5] b. Create the following arrays: Array name Data type Values catColors String white, blue, chocolate, cinnamon, lilac, red, cream, and brown dogColors String black, brown, white, and red c. Using a loop, generate 100 random numbers between 0 to 1000 If the random number is even Create a Cat object using the modified constructor in Phase 2. Generate the constructor's arguments as follows: name = Cat_i where is the random variable value. color = randomly select one color from catColors array. Add the Cat to the shelter. If the random number is odd, Create a Dog object using the modified constructor in Phase 2 Generate the constructor's arguments as follows: name=Dog i where i is the random variable value. o color = randomly select one color from dogColors array. Add the Dog to the shelter. d. Display the list of cats and the list of dogs' names in the shelter. e. Display who needs help. f. Adopt a cat 20 years or older. 9. Adopt a brown dog h. Display the shelter information Submission Each time create a Zip file from your project folder and submit it via Moodle BigLab7 links Grading Breakdown: Studentjava (20 points) Cat.java (5 points) Dog java (5 points) PetShelter java (30 points) Main class code - Creating objects and calling the methods (30 points) JavaDoc of Student, Cat, Dog, and PetShelter classes (10 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

4. In Exercise 3, are the random variables X and Y independent?

Answered: 1 week ago

Question

1. Which position would you take?

Answered: 1 week ago