Create your own UML diagram — similar to the above UML diagram — for a Pet class that meets the specification below.
1. Create the fields indicated below. Use these names exactly as given for your fields. Define them in exactly this order
. • name — The name of the pet, e.g., “Rufus”, “Mittens”, “Smelly”, etc.
• animal — The type of pet, e.g., “dog”, “cat”, “asparagus”, etc.
• age — The (integer) number of years the pet has been alive, e.g., 1, 2, 3, etc.
2. Create a mutator for each of the above in the order listed. Use the standard Java naming convention for mutators.
3. Create an accessor for each of the above in the order listed. Use the standard Java naming convention for accessors.
4. After creating and drawing the UML diagram, take the UML PreLab quiz and enter each line of data you created for your Pet UML diagram.
Example: Suppose you are taking the quiz for the example Car UML above instead of your Pet UML. Don’t enter any spaces at all. When the quiz asks: Enter line 1: You would enter: Car
When the quiz asks: Enter line 2: You would enter: -make:String
When the quiz asks: Enter line 3: You would enter: -yearModel:int
When the quiz asks: Enter line 4: You would enter: +setMake(make:String):void
Don’t enter any of the figures representing the sides of the box
import java.io.*;
import java.util.Scanner;
class Pet //class Pet
{
String name; //members of the class as private
String animal;
int age;
public Pet()//default constructor
{
}
public void setName(String name)//method to set name with the passing argument
{
name = name;
}
public void setAnimal(String animal)//method to set animal type passing argument
{
animal = animal;
}
public void setAge(int ag)//method to set age of animal
{
age = ag;
}
public String getName()//get name of the animal
{
return name;
}
public String getAnimal()//get animal type
{
return animal;
}
public int getAge()//get animal age
{
return age;
}
}//closing class
class Main//test class
{
public static void main(String []args)
{
String na,type;//needed variables
int year;
Pet p = new Pet();//create objects of the class
p.setName("Rufus");//call mutators for all methods
p.setAnimal("Dog");
p.setAge(5);
na = p.getName();//call accessors and get value, save it to variable
type = p.getAnimal();
year = p.getAge();
System.out.println("Name: "+na +"\nAnimal: "+type +"\nAge: "+year);//print all information
}
}
Programming Assignment 5: UML Diagram Objectives: After successfully completing this assignment, students will practice Object Oriented design by creating an UML diagram for a Java program. Program Statement: Bank System You were asked to create a simple UML diagram for a bank system. Each bank has a specific identification number, a name, and a location that needs to be stored. Tellers serve customers’ loans, checking and savings accounts. The bank must know each tellers’ name and identification number for record...
UML Class Diagram with Inheritance
Objectives
Use UML
Correctly indicate inheritance
Demonstrate permissions
Understand inheritance relationships
Labwork
Please read all of the directions carefully.
You will create a UML class diagram reflecting the class hierarchy
for a fictional program that manages university personnel as
constructed according to the graph displayed below. You will need
to think about the attributes and behaviors that are unique to each
class, and also those attributes and behaviors that are common
amongst the subclasses and...
Draw the UML DIAGRAM ALSO
PLEASE DRAW THE UML DIAGRAM.ALSO
in java
should use the program in java
For this task you will create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y and z. You will then use the class to perform some calculations on an array of these points. You need to draw a UML diagram for the class (Point3D) and then implement the class The Point3D class will have the...
Once your UML diagram is complete implement the class naming the Java file MyInteger.java. Create another Java file, a program named MyIntegerTester.java that tests all methods in the class. One technique is to write both classes at the same time. As much as possible you implement and test one method at a time. This minimized the amount of new code you have to look at when debugging a method. Only the Version 4.0 “tester” file will have main() method in...
**CODE in C++ **Include the UML and Class activity diagram. ABC pies sells two types of pies (pumpkin and pecan ) and allows customers to order a specific number of pies. When an order is made, the overall price is calculated based on the type of pie. If a pecan pie order is made, you get a discount of half off from the total price if the season fall or winter. If the season is summer , $2.50 should be...
Create a UML diagram describing a collection of classes for use in an automatic exam grading software. The software should be usable by teachers and students. Teachers should be able to write and administer exams with the software. All exam questions will be multiple choice, with one correct answer. Each question may be worth a different number of points. Teachers may add, remove, and edit questions until they publish the exam. Teachers must set a deadline for the exam before...
Java Programming Exercise: Creating and implementing a UML class diagram The inventory of a library is a set of media. Media can be books, CDs and films. Each medium has a unique alphanumeric ID, a title, a year of publication and the date on which it was purchased. Each book also has an author and an ISBN. For each CD the artist and the number of titles are saved. Each movie has a genre and a format: either DVD or...
What is the code for this in Java?
Assignment Inheritance Learning Objectives Declare a subclass that derives from a superclas:s ■ Demon "Declare a variable of the superclass type and assign it an instance of the subclass type strate polymorphic behavior Access the public members of the superclass type Notice how the overridden versions of the subclass type are called Notice how the subclass specific members are inaccessible "Create an array of superclass type and use a foreach loop to...
JAVA basic quiz.
1. a) In order to run a java program, the computer must first compile the .java files to create .class files. Then the Java Virtual Machine (JVM) runs the .class files. After compilation, when the JVM first starts to run the program, what is created in memory first? When do instances of an object get created? How long do they stay in memory? Under what circumstances will the JVM delete an object from memory? b)What are the...
2. Activity Directions: Create a UML diagram and then write the code for the object classes needed for your UNO game. You will need a minimum of three classes: a. A Card class (models an individual UNO card) b. A Hand class (models a player's hand) c. A Deck class (models the entire UNO deck) You may add other classes as you see fit. Test your program by writing a console application (a driver program) that creates a deck of...