1. Engineering
  2. Computer Science
  3. can i get help with this lab 02...

Question: can i get help with this lab 02...

Question details

Can I get help with this?

Lab 02 Instructions(1).pdf (SECURED) - Adobe Reader File Edit View Window Help Open 貯め目参 + 66.7% Tools Fill & Sign Comment Sign In General Information Export PDF This lab will review defining a Class of objects, instantiating objects of that class, and calling methods of an instantiated object. Adobe ExportPDF Convert PDF files to Word or Excel online. Instructions Write a Javs class named Pet to meet the requirements described in the UML Cless Diagram attached to the assignment. Select PDF File: Lab 02 Instructions1) pdf This lab will adhere to the publiched Coding Standards. Failure to tol low the standarda wl have a significant and negative affect on your grade for the lab. 1 file /380 KB Zip your source code and gnly your source code) and submit the zipped folder as an ottachment to the assignment in Blackboard. D0 NOT submit edit backup versions (with thein the file type) or compiled code (class files); submission of either will result in a grade of zero (o). Convert To: Microsoft Word (docx) Provided to You Recognize Text in English(U.S.) Change The tollowing resourcas are provided: . * * These instructions, including sample tostring output The UML Class Diagram for class Pet A test herness to use in testine your Pet.java code NOTE: Grading does not use the provided test harness. The code used for grading wil verify that your submitted code follows the published Coding Standards. Convert Requirements The provided UML Clas Diagram describes the requirements tor the class Pet. In addtion to the requirements described there, be aware of the requirements included in the Coding Standards. Specifically be aware of the fol lowing: - Create PDF Edit PDF Combine PDF Send Files Store Files * AI get and set methods must be named according to industry standards, based on the provided * All gt and set methods must be final methods.(we wil disouss this atgreater length in the lecture class.) * The only direct access to instance variable values is through the set and get methods, no other direct access is every permitted Expected toString Output Your output need not be identical to that shown here, but you MUST include all inctance values in the output, in the order shown Spot, whose fur-parent is Data, is a Cat, born on 1991/01/05 Mr. Ed, whose fur-parent is Nilbur, is a Horse, born on 1961/81/84 4-36 PM O Type here to search 1/26/2019 2

UML Class Diagram Pet.pdf (SECURED) Adobe Reader File Edit View Window Help | 1 | / 1 -+ | 7596 %- Tools Fill & Sign Comment Click on Sign to add text and place signatures on a PDF file Pet Attributes Pets speCAS (NOTE not breed Pets perent (。 ner) name Operations Default or null constructor; returns a reference to冫fully functional Pet constructor accepting four [4) parameters, alf type String Returns 8reference to publik ccconstructor Pet ( name: String fuly formed end pac String, parent: String Pet objact public setSpeciesl aSpecies String ): void String object llocal name: aspeciesl and asses t to the instance vanable species String obiect llocal name: aParent) and a public setbirthdaytaDD public getSpecies) public cetBirthday oid cepts String object (locel name:800ayl and assigns to the instance varieble bi Returns the current vale of instance varisble Returns the current vale of instance variable birthday ublic tos Returns a fonmatted S a verbose description of the Pet object 4-38 PM O Type here to search 1/26/2019 2

/*
*   Lab 02
*
* Test harness provided to students to test class 'Pet'.
*
* MAKE NO CHANGES TO THIS TEST HARNESS!
*
*
* (c) 2019, Terri Davis
*/
import java.util.Scanner;                           // Scanner class to support user input

public class TestPet
{
/*
   * All the 'work' of the process takes place in the main method. This is actually poor design/structure,
   *   but we will use this (very simple) form to begin the semester...
   */
public static void main( String[] args )
{
    /*
     * Objects & Variables required for processing
     */
    Scanner input = new Scanner( System.in );       // Set the keyboard as the input device for this process
  
    String name,                                   // These String objects will hold the user input to be used
            species,                                //   when calling the full constructor method of class Pet.
            parent,                                 // For simplicity, we have used the same names here as the
            birthday;                               //   names given to the instance variables in the Class definition.
  
    boolean again = true;                           // This boolean controls the while loop we will use.
    String response;                               // This String holds the user's response re: continuing the loop.
  
    Pet spot = new Pet( );                          // This is simply a 'holding space' for the object(s) we create.
  
    while( again )                                  // Continue the loop until the user says otherwise...
    {
      // Collect the necessary input from the user
      System.out.println( "Please enter the pet's name: " );
      name     = input.next( );
      System.out.println( "Please enter the pet's species (NOT breed): " );
      species = input.next( );
      System.out.println( "Please enter the pet's parent's name: " );
      parent   = input.next( );                     
      System.out.println( "Please enter the pet's birthday in yyyy/mm/dd format: " );
      birthday = input.next( );
    
      // Using the user-provided data, INSTANTIATE a Pet object by calling the full constructor
      spot = new Pet( name,                         // User-provided Pet name
                      species,                      // User-provided Pet species
                      parent,                       // User-provided Pet parent
                      birthday );                   // User-provided Pet birthday
    
      // Using the Pet object named 'spot', call the toString method and output the results
      System.out.printf( "%n %s",
                         spot.toString( ) );
    
      // Ask if the user wants to enter another Pet
      System.out.printf( "%n%nDo you wish to enter another Pet? (Yes or No)" );
      response = input.next( );
    
      // Test the user input
      if( response.equals( "No" ) )
        again = false;
    
    } // end while loop
  
    // Let user know we are finished
    System.out.printf( "%n%n Thank you!" );
  
} // end main

} // end TestPet

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution