美文网首页
COMP122作业代写、代写Polymorphism留学生作业、

COMP122作业代写、代写Polymorphism留学生作业、

作者: jiepangxiu | 来源:发表于2019-03-04 10:34 被阅读0次

    COMP122 Assessment 1Class Hierarchy; PolymorphismDue 2019-03-08 at 5pm COMP122 Assessment 1 Due 2019-03-08 at 5pmPart IThe aim is to design, implement, and test a Java program to simulate a game between two players,each rolling three dice for a number of rounds. In each round both players roll the dice. This gainsthem points and the player with a higher score wins the round. Any outcome of the roll of three 6-sideddice can be classified into exactly one of four cases, and will gain points as follows.Case Description Scoring Function Example Pointsall the same All three values are the same sumOfDice + 50 3, 3, 3 9 + 50 = 591, 1, 1 3 + 50 = 53a Run sequence of values that are all di�erent sumOfDice + 30 4, 5, 6 15 + 30 = 453, 1, 2 6 + 30 = 36a Pair exactly two values are the same sumOfDice + 20 1, 1, 4 6 + 20 = 265, 1, 5 11 + 20 =31all di�erent All values are di�erent and it isn’t a run sumOfDice 2, 3, 6 115, 1, 4 10Part I of the assignment builds on the ThreeDice class which is given to you and must not be altered.It implements a class that records the rolls of three dice and includes methods that can be used toclassify each of four possible outcomes above. It’s class diagram is below.ThreeDicedie1: intdie2: intdie3: int+getDie1(): int+getDie2(): int+getDie3(): int+threeSame(): boolean+runOfThree(): boolean+pair(): boolean+allDifferent(): boolean+printResult(): voidThe ThreeDice class constructor takes three integer parameters as input, each parameter representingthe number shown on one of the dice. Note that the way the class is written, the three numbers givento the constructor have to be the integers 1-6, but can be integers.As you can see, each of the methods threeSame(), runOfThree(), pair(), and allDifferent()2COMP122 Assessment 1 Due 2019-03-08 at 5pmreturns a boolean value (i.e. true or false) that represents whether or not the three dice values canbe classified into that category. Have a look at the code for these methods and convince yourself thatthey will return the correct results. These methods are relying on the fact that the three dice rolls arestored in (non-decreasing) order in the class variables.The printResult() method is provided mainly for testing this class as it prints the values of the threedice, and calls the methods to determine the type of outcome.Requirements for Part Ia) Extend the class ThreeDice by designing a subclass that includes a method that returns thepoints for a particular dice roll according to the points table above. Put this new class into aseparate class file called ThreeDiceScorer.java.Note that you need to specify a constructor for your new subclass (in this case, it will likely justcall the constructor of the parent ThreeDice class), and this subclass needs at least one moremethod to calculate the points score of the three dice.b) Write a program called Game.java that will simulate the game described above. It should askthe user for a (non-negative) number of rounds to play. Your application must store the dice rollsfor the pair of players as an array of objects. This application should output for each round: the dice values, and number of points for each player for those dice values; the winner of each round (the player with the highest points for that round, or no-one ifthey are the same, as ties are possible).At the end the following information should be calculated and displayed: the total number of rounds won for each player; the total points for each player; the average points for each player (i.e. total points divided by the number of rounds played); the player with the highest points total.Rather than asking for user input for each dice roll, use randomly generated numbers between 1and 6 (inclusive). You can use Math.random() or java.util.Random for this (recall Practical2, Exercise 6).Note: You may add other classes (in addition to ThreeDiceScorer.java) that are used byyour application. Your report (see submission instructions below) should contain descriptionsand class diagrams of all your classes.An example run for Game.java is as follows.3COMP122 Assessment 1 Due 2019-03-08 at 5pm1 Input the number of rounds to play (min 0): 52 Round 1 Player 1: 1 2 2 Points: 25 Player 2: 1 1 5 Points: 27Round winner is player 2.3 Round 2 Player 1: 2 3 3 Points: 28 Player 2: 1 3 3 Points: 27Round winner is player 1.4 Round 3 Player 1: 3 5 5 Points: 33 Player 2: 3 4 5 Points: 42Round winner is player 2.5 Round 4 Player 1: 1 3 6 Points: 10 Player 2: 1 4 5 Points: 10Round is tied!6 Round 5 Player 1: 1 1 3 Points: 25 Player 2: 1 5 6 Points: 12Round winner is player 1.78 Total wins:9 Player 1: 2 Player 2: 210 Total points:11 Player 1: 121 Player 2: 11812 Average points per round:13 Player 1: 24.2 Player 2: 23.61415 Overall points winner is player 2.c) Write a separate program, called Average.java, that will compute the average number ofpoints over all possible rolls of three six-sided (fair) dice. (How many such combinations of thethree dice are possible? See your COMP109 notes to remind yourself.) Average.java should (ofcourse) make use of your ThreeDiceScorer.java class that you designed above.d) Suppose that instead of three fair six-sided dice, two of the dice are normal (fair) six-sided dice,and that the third six-sided die has the numbers 2, 3, 4, 5, 6, 6 (where each of the possible sixsides of this die occurs with equal probability). What is the average number of points over allpossible rolls of these dice?You only need to state the average here, and how it compares to the average you have obtainedin c).4COMP122 Assessment 1 Due 2019-03-08 at 5pmPart IIThis part of the assessment is about designing a hierarchy of Java classes. The idea here is that you arewriting a program to display information to a potential client for a company that supplies combinedbroadband, TV, and mobile phone packages.This company (currently) provides three di�erent broadband, TV, and mobile phone packages whichare summarised below. Each account type has a basic flat cost (per month), and additional chargesthat depend upon the number of minutes used on the phone and broadband usage charges.Bronze Silver GoldPackage Costs (monthly) £35.00 £45.00 £60.00Daytime phone costs (per minute) 12p 12p 0pEvening/Weekend phone costs (per minute) 5p 0p 0pNumber of TV Channels 60 130 230Broadband (included per month) 200GB 300GB 2000GBBroadband (per GB above included amount) 20p 10p 10pAdditionally, the Silver and Gold accounts provide a free Spotify account, and Gold accounts includemusic on demand.For this part of the assessment you are going to use Java’s inheritance mechanism to implement a setof classes to store information about the company’s packages, and display costs to a potential client.Requirements for Part IIa) A user should be able to input the number of daytime phone minutes that she/he uses, thenumber of evening/weekend minutes that she/he uses, and the amount of broadband usage,expressed in Gb (megabytes), for a given month. These values should all be integer values, greaterthan or equal to zero (i.e. negative values should be disallowed and the user asked to re-inputthese values).b) For each account (Bronze, Silver, and Gold), the account information should be printed, the totalcost of each type of call should be calculated and printed, the total cost for (extra) broadbandusage, and the total cost of that account (made up from the call costs, broadband costs, plus thepackage costs) should be calculated and printed.5COMP122 Assessment 1 Due 2019-03-08 at 5pmc) Additionally, the program should output which account has the total cost that is the cheapest. Iftwo (or more) accounts have the same cost, which would you recommend to the customer?See an example of output below. Call your application program AccountUser.java.d) Suppose that the company wants to introduce a ‘Platinum Account’, which has a monthly cost of£75, increases the number of TV channels to 275, and has unlimited broadband (i.e. no additionalcosts on a per GB basis). Otherwise, all other features about the Platimum Account are the sameas the Gold Account.How could you implement this additional account, in terms of your class hierarchy and the wayyou have implemented your application program?This question requires no code to be written, just a short description in your report for the assessment:Describe clearly what you would do to add this new account type. What would you do interms of Java programming, e.g. modifying/overriding methods, adding new constants, etc?Example program output1 Please enter the number of daytime minutes used per month: 1002 Please enter the number of nighttime minutes used per month: 1003 Please enter the number of Gigabytes used per month: 3254 Account Summary for Bronze Account5 Package Cost: 35.006 Cost of daytime calls: 0.12/min7 Cost of evening and weekend calls: 0.05/min8 Number of Channels: 609 Broadband Included: 200GB10 Broadband Cost (above included limit): 0.2/GB11 Total daytime calls cost: 12.0012 Total evening calls cost: 5.0013 Total (extra) broadband cost: 25.0014 Total cost: 77.001516 Account Summary for Silver Account17 Package Cost: 45.0018 Cost of daytime calls: 0.12/min19 Cost of evening and weekend calls: 0.00/min20 Number of Channels: 13021 Broadband Included: 300GB22 Broadband Cost (above included limit): 0.1/GB23 Total daytime calls cost: 12.0024 Total evening calls cost: 0.0025 Total (extra) broadband cost: 2.506COMP122 Assessment 1 Due 2019-03-08 at 5pm26 Total cost: 59.5027 Spotify Account provided2829 Account Summary for Gold Account30 Package Cost: 60.0031 Cost of daytime calls: 0.00/min32 Cost of evening and weekend calls: 0.00/min33 Number of Channels: 23034 Broadband Included: 2000GB35 Broadband Cost (above included limit): 0.1/GB36 Total daytime calls cost: 0.0037 Total evening calls cost: 0.0038 Total (extra) broadband cost: 0.0039 Total cost: 60.0040 Spotify Account provided41 Music on Demand provided4243 Silver Account is cheapest cost.Hints/Suggestions You will need (at least) four Java classes: BronzeAccount, SilverAccount, GoldAccount,and an application class. I suggest making an abstract class called (for example) StandardAccount that will bethe base class of a hierarchy of classes. The classes BronzeAccount, SilverAccount, andGoldAccount can each extend this StandardAccount class.Make the class attributes in StandardAccount protected (not private) because then subclassesthat extend StandardAccount can easily modify these class attributes as appropriate.With careful thought and planning, most of the Java code for the program operations (suchas computing the costs of mobile phone charges, broadband charges, etc) can be placed inthe StandardAccount class. These methods can be overridden (if needed) in the classes thatextend it. So the code for the BronzeAccount class can be quite short (similarly for the otherclasses that extend StandardAccount).You could also include, for example, an abstract method in StandardAccount calledaccountType() which returns a String for the type of account (e.g. ‘Bronze’). Sincethat method is abstract, it must be overridden (implemented) in the classes that extendStandardAccount.7COMP122 Assessment 1 Due 2019-03-08 at 5pm Try to put as much data and related calculations into a StandardAccount class, that each otherclass will extend, in order to avoid code duplication. I also suggest it can be useful to create a Java interface that will contain various constantsthat describe the charges per minute, (extra) broadband charges per GB, number of channelsincluded in the package, etc. Each class can implement this interface and then have access tothe constants which are all in one place.Submission Instructions Deadline: Friday, 8 March 2019, 5:00pm (Friday of Week 6) Submission server: https://sam.csc.liv.ac.uk/COMP/Submissions.plYour submission should be a single compressed .zip file called comp122_assessment_1_SID.zipwhere SID should be replaced by your student ID. This file should include:1. Your implementation These must include the .java source files, not .class files! For Part I you should include the (unchanged!) file ThreeDice.java so that your codecompiles directly. Put all files for Part I into a subdirectory called part_1, and everything for Part II in adirectory part_2 accordingly.2. A report. This must be a .pdf file and should contain sections as follows. Requirements: A Summary of the above requirements statement in your own words. Analysis and Design: A short (one paragraph) description of your analysis of the problem includinga Class Diagram outlining the class structure for your proposed solution, and pseudocode formethods. Again, do this for each part of the assessment. Testing: A set of proposed test cases presented in tabular format including expected output, andevidence of the results of testing (the simplest way of doing this is to cut and paste the result ofrunning your test cases into your report).8COMP122 Assessment 1 Due 2019-03-08 at 5pmMarking SchemeEach part counts 50% towards the final mark of this coursework. Marks will be awarded for: Analysis and Design 10% (This includes things like UML diagrams for your classes/application,justification for how/why you structure your classes, appropriate pseudocode for methods, etc.) Implementation 25% (This includes correctness of your programs, appropriate level of comments,correct indentation so your code is readable, having useful identifiers, etc.) Testing 10% (Have you done suitable testing in terms of checking di�erent paths through yourcode, checking what you do with ‘unexpected’ inputs, a su�icient number of tests, etc. Extra questions 5% such as in Part I c) or d) or Part II d).If your Java source files do not successfully compile and run on departmental computer systems youwill su�er a penalty of 5 marks. This applies to both parts of the assessment separately.If you use any form of compression other than zip or your report is not a PDF format, you risk yourfiles not being read by the assessors, resulting in a mark of 0! If your files can be read, you will still lose5 marks from your final grade.Your submission is an individual piece of work. No collaboration with other students is allowed!Expect that plagiarism detection so�ware will be run on your submission to compare your work tothat of other students. Late submissions and plagiarism/collusion are subject to the University Code ofPractice on Assessment 11https://www.liverpool.ac.uk/media/livacuk/tqsd/code-of-practice-on-assessment/code_of_practice_on_assessment.pdf本团队核心人员组成主要包括硅谷工程师、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代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp

    相关文章

      网友评论

          本文标题:COMP122作业代写、代写Polymorphism留学生作业、

          本文链接:https://www.haomeiwen.com/subject/agsbuqtx.html