<p>代写Interitance的小练习作业,求图形的边长和面积。</p>
<h2 id="Requirement">Requirement</h2>
<p>In this exercise, we will be working with inheritance, and thinking about how we can set up our inheritance hierarchy to make our lives easier. There is an easy way and a difficult way to complete this exercise. If you plan appropriately, you’ll find you won’t have to write very much code at all.</p>
<h2 id="Shapes">Shapes</h2>
<p>Consider the following 4 shapes:</p>
<h3 id="Parallelogram">Parallelogram</h3>
<p>A four sided figure with parallel pairs of sides. A Parallelogram is defined by the lengths of its two pairs of sides (labelled base and side in the picture below) and the interior angle (in degrees) between adjacent sides (labelled theta in the picture below).</p>
<h3 id="Rectangle">Rectangle</h3>
<p>A parallelogram with four right angles. A Rectangle is defined by the lengths of its two pairs of sides (labelled base and side in the picture below).</p>
<h3 id="Rhombus">Rhombus</h3>
<p>A parallelogram with four equal sides. A Rhombus is defined by the length of its sides (labelled base in the picture below) and the interior angle (in degrees) between adjacent sides (labelled theta in the picture below).</p>
<h3 id="Square">Square</h3>
<p>A parallelogram with four equal sides and four right angles; both a Rectangle and a Rhombus. A Square is defined by the length of its sides (labelled base in the picture below).</p>
<p>Your first task is to figure out the IS-A hierarchy of these shapes. Draw it out in a piece of paper. Are there any instances of multiple parents?</p>
<h2 id="Your-Task">Your Task</h2>
<p>You must write four classes: Parallelogram, Rectangle, Rhombus and Square, ensuring that the class hierarchy follows your diagram from the previous step. You may create additional classes if you wish (are there any good reasons why you might want to do this?). The parameters of init methods should always be input in the following order: (base, side, theta) (theta being given in degrees), though of course, not every class’ init will take all three. So for example, a Rectangle will only take (base, side).</p>
<p>Objects of these classes must have the following methods:</p>
<ul>
<li>area() - returns the area of the shape
<ul>
<li>Note: The area of a parallelogram is computed by base <em>side</em> sin(theta)</li>
<li>Warning: function math.sin in Python expects its argument to be an angle given in radians - take a look at the function math.radians to convert between degrees and radians.</li>
</ul>
</li>
<li>bst() - returns a list of three floats: [base, side, theta]. Even if a shape doesn’t need one of the parameters for its input, it should still be able to return it. (e.g., a 10 x 10 square would return: [10.0, 10.0, 90.0]).</li>
<li>When printed, each shape should return a string with text in the following format “I am a shape with area area”. Four example, a 10 x 10 square would return the string: “I am a Square with area 100”.</li>
</ul>
<h2 id="Be-Lazy">Be Lazy</h2>
<p>One way to solve this would be to write four completely independent classes, and have each class completely implement all of their own functions. This would be a bad idea (why?). If you use inheritance correctly, you should find the exercise much simpler. Remember, you should never calculate something when you can just get another method to do the work for you. Hint: It’s possible to set more than one parent for your class. Are there any shapes here for which that would be a sensible thing to do?</p>
<h2 id="What-to-Submit">What to Submit</h2>
<p>All of your code should be submitted to MarkUs in a file called ex9.py that doesn’t import anything other than math, and does not ask for input or print anything when imported.</p><br>
<br>本团队核心人员组成主要包括硅谷工程师、BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。
我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:
C/C++/C#代写
Java代写
IT代写
Python代写
辅导编程作业
Matlab代写
Haskell代写
Processing代写
Linux环境搭建
Rust代写
Data Structure Assginment 数据结构代写
MIPS代写
Machine Learning 作业 代写
Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导
Web开发、网站开发、网站作业
ASP.NET网站开发
Finance Insurace Statistics统计、回归、迭代
Prolog代写
Computer Computational method代做
<br>
<span STYLE="color:white;background:red;mso-highlight: red">因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp </span>
网友评论