Starting from:

$25

IT2650-Assignment 11 Solved

Step 01 - Compile the following code  
 

This assignment is actually very straightforward – if not simple. While the assignment may be straightforward, the concepts are not. 

This assignment ties in most of the major concepts of building objects from other objects – using Inheritance as well as composition.  

The task is not to write any new code, I simply want you to understand the concepts and assemble the code and get it to work. 

I want you to take the following UML Object Model and create the code stubs. 

  

By code stubs, I mean that you should create a project that includes the following Java files within the project, all with the methods and attributes specified by the various class diagrams.  

Here are some major hints. 

interface Nameable {    public abstract String getName();    public void setName(String n);  } 
 

abstract class Mammal {    public void generateHeat() {       System.out.println("Generating Heat"); 
   } } 
                

class Dog {    Head head; 

   String name; 

 

   public void makeNoise() { 

      System.out.println("Bark"); 

   } 

    

   public String getName() { 

      return name; 

   } 

    

   public void setName(String n){ 

      name = n; 

   }  

    


 

class Head { 

 

   double headSize; 

 


Finally, you will create a main application class called TestDog where you will create a single Dog called 

Fido  

public class TestDog { 

     

    public static void main(String[] args) { 

              

             Dog fido = new Dog(); 

              

             fido.makeNoise(); 

              

             fido.setName("Fido");                System.out.println("Name = " + fido.getName());
 

    } 


 

The primary task here is to assemble everything so that it works! You don't have to write the code - just assemble it!  

 

Step 02 – Run the code (the output should look something like this) 
 

  

More products