Question: Question 1. Consider a class Book that contains information about a Book. The class should have the following attributes: The title of the book The
Question 1.
Consider a class Book that contains information about a Book. The class should have the following attributes:
- The title of the book
- The author of the book
- Year of publication (e.g. 2001)
- The number of people that have rated this book as a 1 (Terrible)
- The number of people that have rated this book as a 2 (Bad)
- The number of people that have rated this book as a 3 (OK)
- The number of people that have rated this book as a 4 (Good)
- The number of people that have rated this book as a 5 (Great)
- Implement the class withaccessors and mutatorsfor the title of the book, author of the book and year of publication. a methodaddRatingthat takes an integer as an input parameter. The method should verify that the parameter is a number between 1 and 5, and if so, increment by one the number of people rating the book that matches the input parameter. For example, if 3 is the input parameter, then the number of people that rated the book as a 3 should be incremented by one. another method,getAverage, that returns the average value for all the book ratings.
- Test the class by writing a main method that creates at least two Book objects, adds at least five ratings for each book, and outputs the title of the book, author of the book, year of publication, and average rating for each book object.
- Provide the UML class diagram for the Book class.
- Note that the question does not require the use of arrays. However if you want to use arrays, you are allowed to use them.
ICT167 Assignment 12TS, 2019
The program should be well-structured and should have a reasonable set of methods in addition to the main method. It should use a good coding style, proper indentation, meaningful identifier names and appropriate comments throughout.
The program should also include a method (eg, StudentInfo( )) to output your student details (name, student number, mode of enrolment (i.e., internal or external), tutor name, tutorial attendance day and time) at the start of program results.
Devise suitable test data (in addition to the above example) to test your program. The test data together with test results should be submitted as part of your external documentation.
Question 2.
Hangman is a game that can be played between two players. One player thinks of a word and the other tries to guess it by suggesting letters. The word to guess is represented by a row of dashes, giving the number of letters in the word. If the guessing player suggests a letter which occurs in the word, the other player writes it in all its correct positions. Seehttp://en.wikipedia.org/wiki/Hangman_(game)
for further details.
Design, write in Java, test and document a program which will allow a user to play a simplified version of the hangman game. The program will display the secret word in its disguised form (a row of question marks (?), and invite the user to enter an alphabetic letter. If the letter occurs in the secret word, the program will display it in all its correct positions and ask the user to enter another letter as a guess. The process continues until the user guesses the word correctly! The program will also display a running total of the number of guesses made and the number of wrong guesses.
Design two classes for this program -a class that could be used to play a simplified version of the hangman game (as described in the above paragraph) and a client class that uses the hangman class.
Provide the UML class diagram for the hangman class.Thehangman classwill have at least the following attributes:
The secret word or phrase (a String, which may include embedded white spaces and punctuation characters)
The disguised word, in which each unknown alphabetic letter in the secret word is replaced with a question mark (?). When an unknown letter is guessed correctly, it will replace the corresponding question mark(s) in the disguised word. For example, if the secret word isabracadabraand the lettersaandbhave been guessed, the disguised word would beab?a?a?ab?a.
The number of guesses made.
The number of incorrect guesses.
Thehangman classwill have at least the following methods (write the preconditions and postconditions of each method) :
makeGuess(ch) guesses that character ch is in the word.
getDisguisedWord returns a String containing correctly guessed letters in their correct
positions and unknown letters replaced with?.
getSecretWord returns the secret word.
getGuessCount returns the number of guesses made.
isFound returns true if the hidden word has been discovered.
Devise any additional methods and attributes that are needed in the class and are not listed above. Note that when treating letters of the alphabet, case is not important (i.e., the uppercase and lowercase forms of the same letter are to be treated the same).
ICT167 Assignment 13TS, 2019 aclient classthat tests the hangman class. The client class should allow the user to play three games of hangman. The client class will have the three secret words (or phrases) built into it as String variables. Note that the client class only needs to have the main method which creates an object of the hangman class, sets the secret word and passes control to the hangman class. The client program should handle the flow of the main program including looping and branching, and only use the hangman class for playing the game.
The test results from the program should be submitted as part of your external documentation.
Your program should also include a method (eg, StudentInfo( )) to output your student details (name, student number, mode of enrolment, tutor name, tutorial attendance day and time) at the start of program output.
Here is some sample output (the user input is inbold): Let's play a round of hangman.
We are playing hangman
The disguised word is
a
Correct. Guesses made 1 with 0 wrong
The disguised word is
Guess a letter:
7
Sorry, your guess must be an alphabet character from a to z Guesses made 1 with 0 wrong
The disguised word is
Guess a letter:
p
Incorrect. Guesses made 2 with 1 wrong
The disguised word is Guess a letter:
ha
Sorry, bad guess. Need a single letter. Guesses made 2 with 1 wrong
The disguised word is Guess a letter:
h
Correct. Guesses made 3 with 1 wrong
The disguised word is
Guess a letter:
r
Incorrect. Guesses made 4 with 2 wrong
The disguised word is
l
Correct. Guesses made 5 with 2 wrong
The disguised word is
ICT167 Assignment 1
s
Incorrect. Guesses made 6 with 3 wrong
The disguised word is
n
Correct. Guesses made 7 with 3 wrong
The disguised word is
Guess a letter:
0
Sorry, your guess must be an alphabet character from a to z Guesses made 7 with 3 wrong
The disguised word is
o
Correct. Guesses made 8 with 3 wrong
The disguised word is
Guess a letter:
b
Incorrect. Guesses made 9 with 4 wrong
The disguised word is
Guess a letter:
c
Correct. Guesses made 10 with 4 wrong
The disguised word is
Guess a letter:
y
Correct. Guesses made 11 with 4 wrong
Congratulations, you found the secret word: halcyon ***************************************************
Let's play a second round of hangman. We are playing hangman
The disguised word is '?? ?? ????.> Guess a letter:
b
Correct. Guesses made 1 with 0 wrong
The disguised word is '?? b? b???.>
Guess a letter:
9
Sorry, your guess must be an alphabet character from a to z Guesses made 1 with 0 wrong
The disguised word is '?? b? b???.> Guess a letter:
.......
.......
The above example did not show how the user can exit the program. Think of a way that you can allow the user to exit the program (not using Ctrl+C)
4TS, 2019
ICT167 Assignment 15TS, 2019
Distribution of marks for assessment
For each of the programming questions, an approximate distribution of marks for assessment is given below. Each question will be marked out of 50 as follows:
Correct solution design and implementation: 25 marks
Programming style (internal documentation (comments), use of methods, parameters, input validation, readability, presentation of output etc.): 12.5 marks
External Documentation (problem specification, algorithm, program limitations, program listings, program testing and test results etc.): 12.5 marks
For internal documentation (i.e. in the source code) we require:
- a beginning comment clearly stating title, author, date, file name, purpose and any assumptions or conditions on the form of input and expected output;
- other comments giving useful low-level documentation and describing each component;
- well-formatted readable code with meaningful identifier names and blank lines between
- components (like methods and classes).
- Each program should also include a method (eg, StudentInfo( )) to output your student details (name, student number, mode of enrolment, tutor name, tutorial attendance day and time) at the start of program output.
- Required External Documentation for each question:
- Title:a paragraph clearly stating title, author, date, file names, and one-line statement of purpose.
- Requirements/Specification: a paragraph giving a brief account of what the program is supposed to do. State any assumptions or conditions on the form of input and expected output.
- User Guide: include clear instructions on how to access, compile and run the program.
- Structure/Design/Algorithm: Outline the design of your program. Give a written description, a
- UML diagram and use pseudocode for algorithms.
- Limitations:Describe program shortfalls (if any), eg, the features asked for but not implemented, the situations it cannot handle etc.
- Testing: describe your testing strategy (the more systematic, the better) and any errors noticed. Provide a copy of your results of testing in a document saved in Word format.Note that a copy of the sample test data and results from a program run for each program is required (copy from the program output window and paste to a Word file).Your submitted test results should demonstrate a thorough testing of the programs.
- Source program listings: save all your Java source code in a document in MS Word format.
All of the above external documentation for a question must be included in that order in a file saved in MS Word format. Your final external documentation submission should be prepared as a single Word document containing each of the questions in order and each section within these also in order.
It is also necessary to submit the Java source code and compiled version of your programs (i.e., all classes that you have designed and implemented). You should develop the programs using the NetBeans IDE. It will make it easy to collect sample output. The whole NetBeans project(s) should be submitted.
The external documentation together with the source code files and compiled versions for all questions must be compressed in a .zip file before submitting. Note that the whole NetBeans project
ICT167 Assignment 16TS, 2019
folders can be zipped. Make sure that all necessary files are submitted so that the programs can be viewed, compiled and run successfully.
The final versions of the programs should compile and run under Java SE (JDK). Internal students should test compilation and running on the University lab machines.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
