RBE104TC 分析

阮小七
• 阅读 626

RBE104TC C/C++ Programming Language
Assignment 2

Assignment Overview:

This assignment aims at testing some basic concepts of the C++ programming and
initiates the routine of code development using the software development process
(SDP) presented in the relevant lectures. It focuses on the following five steps of
the SDP.

  1. Problem statement: formulate the problem;
  2. Analysis: determine the inputs, outputs, variables, etc.;
  3. Design: define the list of steps (the algorithm) needed to solve the
    problem;
  4. Implementation: the C code has to be submitted as a separate file, just
    indicate here the name of the file;
  5. Testing: explain how you have tested and verified your C program.
    You will need to apply this methodology to each one of the following simple
    exercises.
    Things to note:
  6. Include clear comments in your code to make it easy to understand.
  7. Explain your testing procedure and what you have observed during the
    testing. The testing should be demonstrated by screenshot pictures to
    present the actual implementation output.
  8. How you solved any problems.
    Contribution to the Overall Marks 60%
    Issue Date
    Submission Deadline Dec. 23rd, 2020
  9. / 5
    Exercise 1:
    Design a new class to represent a fraction (a
    nation of two integer values).
    The data members of the class Fraction are two
    integers, top and down, denoting the numerator
    and denominator, respectively.
    class Fraction
    {
    private:
    int top; // Numerator
    int bottom; // Denominator
    public:
    . . . . . .
    };
    Part 1: Fundamental requirements for the class Fraction.
  10. Fractional numbers can be declared with both a numerator and denominator,
    or simple numerator:
    Fraction a; // represents 0/1
    Fraction b(3,4); // represents 3/4
    Fraction c(5); // represents 5/1
  11. Fractions should be able to act just like other numbers.
    Add, subtract, multiple and divide;
    Compare based on values;
    Input and output.
    Part 2: Advanced requirements
  12. Fractional number is normalized to ensure that only the numerator can be
    negative and the value is in the least common denominator form:
    • 2/-3 would be converted into -2/3 automatically;
    • 15/21 would be converted into 5/7 automatically.
  13. Write methods to convert between decimals and fractions.
    Exercise 2:
    Derive a sub-class iFraction from the base class Fraction, which was designed by
    you in Exercise 2 of Assessment 2. The iFraction class represents the mixed
    fractions like ;
    Part 1: Design the sub-class iFraction:
    • It should have a constructor for initialisation;
    • It should contain a method to display the mixed fraction on screen;
    Part 2: Design an external function convertF (not function member of class Fraction
    and iFraction) to convert the improper fractions to mixed fractions.
    Hint: convertF can be the friend function of those two classes.
    Exercise 3:
    Design a composite class that represents complex numbers whose real and
    imaginary parts are Fractions.
    • Write appropriate constructors for this class;
    • Complex numbers should be able to add, subtract and multiple.
  14. / 5
    Exercise 4:
    This is a computer game with different types of players. Take the code provided for
    the container class (container.h), player class (player.h), and the swordsman class
    (swordsman.h), and the main function (main.cpp).
    Part 1:
  15. Read the source codes, understand the meaning and fill the blank (shown
    as) to make it work;
  16. Generate the CRC cards of the classes: clarify the responsibilities of each
    class, illustrate the collaboration with others, and label all the members’ as
    public, protected, and private. Then draw the hierarchy chart of them;
    Part 2:
  17. Design another two classes, archer and mage. Generate their CRC card
    and put them in the hierarchy chart drew above. Write the code for these two
    classes and make them work (cooperate with the main function);
  18. Modify the main function, to have enemies with all three professions (could
    be randomly chosen).
    Part 3 (Optional):
    Can you involve another attribute – luck, in this game?
    Notes: The factors are imperfect, make the fight too hard or too easy. Change
    whatever you want, but leave hints for reviewers to know what you have done.
  19. / 5
    What should be submitted?
    You should submit the followings:
    1). A short report (up to a few pages of text plus C source codes) detailing for each
    question:
    a). SDP steps 1 to 3 in the report (Report + Specification + Analysis +
    Algorithm Design) (40%);
    b). SDP step 4 (Implementation + Robustness): your C source code including
    the comments. (40%);
    c). SDP step 5 (testing): you will explain how you have tested the correctness
    of your C program and will include some sample runs of your C Programs.
    (20%);
    Please refer to the file Marking Guidelines for RBE104TC.pdf on the Learning Mall
    system for a detailed marking scheme.
    2). The report in Microsoft Word or pdf format and C source code of your
    implementation zipped into a single file, i.e. the zip file will contain 2 files. (It is good
    practice to include comments in your code see the example provided.)
    The naming of Report (.doc, .docx or .pdf only), Source Code (.c) and Compressed
    file (.zip, or .rar only)
    StudentID_LastName_FirstName_AssignmentNumber.doc
    StudentID_ AssignmentNumber.c
    StudentID_LastName_FirstName_AssignmentNumber.zip
    For example:
    Report and c source file named:
    1234567_Albert_Einstein_1.doc
    1234567_1.c
    Contained within the zip file:
    1234567_Albert_Einstein_1.zip
    How the work should be submitted?
    Should be submitted electronically through the Learning Mall system so that the
    marker can run your programs during marking. Feedback and your grade will also
    be given through the Learning Mall system.
    WX:codehelp
点赞
收藏
评论区
推荐文章
blmius blmius
4年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
美凌格栋栋酱 美凌格栋栋酱
7个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
1年前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
4年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
HTTP面试题(二):HTTP请求报文和响应报文格式
!(https://oscimg.oschina.net/oscnet/0406894fb1274bee91fc53c84c516576.jpg)看都看了还不点个赞!(https://oscimg.oschina.net/oscnet/095d444dc9a449ee85afd19b00fdf52b.png)!(h
Stella981 Stella981
3年前
Duang,HUAWEI DevEco IDE全面升级啦
想感受全新UI带来的视觉及交互体验、HiKey970开发板调测、HiAIAPI推荐和收藏、深度AI模型分析等新功能,体验高清晰度和流畅度的远程AI真机调测吗?!(https://oscimg.oschina.net/oscnet/f4e1bb24ff00b8c6ea27f75370a53bfbacd.jpg)全新的UI设计
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Python进阶者 Python进阶者
1年前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这
阮小七
阮小七
Lv1
明朝望乡处,应见陇头梅。
文章
3
粉丝
0
获赞
0