Write an accessor method to get the number of humps

Assignment Help Computer Engineering
Reference no: EM132217553

Zoo Abstract Inheritance Lab

Objective: Students should be able to declare an abstract class. Students should be able to create more subclasses for the class. They should be able to create an array of class objects. They should be able to write a tester program to display all the functionality of their program.

It's good programming style to keep the amount of code to a minimum and to reuse existing code as much as possible. Code that is economical is easy to maintain. The concept of inheritance does just that: it illustrates a way to make code both economical and extendable.

When creating a model using inheritance, you start by defining a more general class with common instance variables and methods. The more specific classes are told to "extend" the general class. The general class then becomes the superclass and the others become the subclasses. The subclasses automatically inherit the instance variables and methods from the superclass.

The result is called the inheritance hierarchy; a simple such hierarchy is shown here. In this case, the Animal class is the superclass. It has two subclasses, Cow and Camel. (This doesn't work in reverse. A subclass can extend only one class.)

Let's model this animal hierarchy.

Write an Animal Class. This will be the superclass.

This class should be declared as abstract because we don't want to be able to create an instance of this class.

This class will have 2 attributes: a name and a sound.

Write a constructor that takes 2 parameters: name and sound.

Write accessor methods only for each attribute.

Write a toString method that prints out the attributes in the form: Spot says woof.

Write a class called Cow. A cow is an animal.

This class will not have any additional instance variables.

Define a constructor that has a name and sound as a parameter.

All methods will be inherited. You do not need to write any additional methods.

Write a class called Camel.

A camel will add an instance variable for the number of humps.

Provide a constructor that accepts 3 parameters: name, sound, and number of humps.

Write an accessor method to get the number of humps.

Override the toString method to display a message in the format: The camel bertha says spit and has 2 humps

Define your own subclass. Your subclass should be unique so be creative.

Write a class called ZooTester.java. Create an array of 5 animals and print out each animal. Be sure to test any additional methods you write.

Reference no: EM132217553

Questions Cloud

Consider the largest positive number that could be stored : The XYZ Computer Company made a commercially-unsuccessful computer which used 9-bit memory words. It used the 2's complement system.
Discuss kotters theory of change management : HI 6005 Management and Organisations in a Global Environment - Discuss Kotter's theory of Change Management - Discuss Force-Field Analysis: giving examples
What information do you you need to calculate the asumptions : Prepare a excel spreadsheet that you can use to explain your analysis of the retail listing 10660 SW 40th St, Miami, Florida, 33165.
Why is it good news that the disease is rare : Why is it good news that the disease is rare? What are the chances that you actually have the disease?
Write an accessor method to get the number of humps : Provide a constructor that accepts 3 parameters: name, sound, and number of humps. Write an accessor method to get the number of humps.
Determine the price of the bonds using given data : When Patey Pontoons issued 8% bonds on January 1, 2018, with a face amount of $860,000, the market yield for bonds of similar risk and maturity was 11%.
A best guess at the number of lines of source code : A graphic table with tasks of the full system duration will be based on your assumptions from (1) above and task dependencies.
Develop a tool for visualization and editing of bezier curve : Appropriate data structures to store the curve properties (number of control points, set of control points, etc.).
Why would bp personnel think they could get away : Why would BP personnel think they could get away with bribing an employee in the Russian anti-bribery prosecutor's office? If a company decides to bribe.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd