Java 代写 | Polymorphism

Java基础,学习如何声明使用抽象函类、抽象方法,继承抽象类、重写方法。

Introduction

 As was taught earlier in the semester, Java allows the declaration of both classes and interfaces. Being an object-oriented programming language, it also allows classes/interfaces to extend/implement others through a concept called inheritance.

 

An interface can be thought of as a contract. Any concrete class that implements an interface must provide declarations for methods contained in it. An abstract class is similar to an interface, in that it requires its concrete subclasses to provide declarations for its abstract methods. Abstract classes, though, can also contains fields and constructors.

 

The power of both interfaces and abstract classes is that types can be related, making an assertion that subtypes have certain methods in common. For example, AbstractList is an abstract class held in the java.util package. It contains a get() method that is marked as abstract. This means that its subclasses, such as ArrayList, must provide a declaration for that method.

 

One can declare a field of type AbstractList, and will know for a fact that any reference it holds has a get() implementation. This allows an existing implementation to be swapped out for a potentially better one, and not break existing code.

 

Description

 

Your task for this homework is to create three classes — Polyhedron, Tetrahedron, and Icosahedron. Polyhedron is an abstract class, of which both Tetrahedron and Icosahedron extend. Field, constructor, and method declarations for each are listed below.

Page 1 of 5 – Problem Solving and Object-Oriented Programming (CS18000)

 

Polyhedron

 Fields

NameTypeAccess Modifier
sideLengthdoubleprivate

Constructor

ParametersAccess Modifier
double sideLengthpublic

 Methods

NameReturn TypeParametersAccess Modifier
getSurfaceArea1doubleNonepublic
getVolume1doubleNonepublic
getSideLengthdoubleNonepublic
setSideLengthvoiddouble sideLengthpublic
equalsbooleanObject anObjectpublic
toStringvoidNonepublic

 Constructor

ParametersAccess Modifier
double sideLengthpublic

 Methods

NameReturn TypeParametersAccess Modifier
getSurfaceAreadoubleNonepublic
getVolumedoubleNonepublic
equalsbooleanObject anObjectpublic
toStringvoidNonepublic

 

Icosahedron

 Supertype

Name
Polyhedron

 Constructor

ParametersAccess Modifier
double sideLengthpublic

 Methods

NameReturn TypeParametersAccess Modifier
getSurfaceAreadoubleNonepublic
getVolumedoubleNonepublic
equalsbooleanObject anObjectpublic
toStringvoidNonepublic

 

Requirements

You are required to declare the three classes mentioned above – Polyhedron, Tetrahedron, and Icosahedron. In order for your work to be graded correctly, please follow the specifications outlined above, and in the JavaDoc.

Submission Instructions

Submit both Polyhedron.java, Tetrahedron.java , and Icosahedron.java to Vocareum through Blackboard. Keep in mind that only your last submission will be considered. Test cases will be used to grade your work.

Grading Rubric

  • Polyhedron class (40 points)
    • 5 points
      • Making Polyhedron abstract
      • Declaring the sideLength field
    • 5 points for each constructor/method declaration (7 total)
  • 30 points
    • Tetrahedron class
      • 3 points for extending Polyhedron
      • 4 points for each constructor/method declaration (5 total)
    • Icosahedron class
      • 3 points for extending Polyhedron
      • 4 points for each constructor/method declaration (5 total)

程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:dmxyzl003 工作时间:全年无休-早上8点到凌晨3点


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

发表评论