CSCI 2540 Assignment 5 solved

$30.00

Original Work ?

Download Details:

  • Name: assg5-dqdot5.zip
  • Type: zip
  • Size: 97.64 KB

Category: Tags: , , You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

Part 1 (30 pts)
Write two recursive methods called replace and replaceAll. Both methods have three
parameters, a string str, a character oldChar, and a character newChar. In the replace method,
replace the first occurrence of oldChar with newChar in the string str and return the new string.
In the replaceAll method, replace all the occurrences of oldChar with newChar in the string str
and return the new string. In both cases, if the oldChar is not in the input string, return the
original string. Both methods have to be recursive.
You also need to write a main method to test the two recursive methods. Your main method
should print a menu such as the following:
1. Test replace method
2. Test replaceAll method
3. Exit
The menu should be repeated until user selects 3 to exit. For each testing, your program should
ask user to enter the input string, the old character, and the new character, each on a separate
line, and then print the output string after calling the corresponding method.
Place all three methods in the same class. Name your class as StringReplaceRecursion. Place
your class in a named package and name your package as assg5_yourPirateId.
Part 2 (40 pts)
You need to write a program to perform JUnit testing on the Point class and ExtendedCircile
class you wrote in assignment 2. An examples of JUnit test has been discussed in class and it is
also available on Canvas. As demonstrated in class, Eclipse can be used for JUnit test (you will
need to create a new JUnit Test Case and add the Junit 4 library). Use JUnit 4 for this
assignment.
You need to write the TestPoint and TestExtendedCircle class which include methods to test
all the constructors and methods in your Point and ExtendedCircle class. Make sure you also
test all the different cases for each method.
For most of the test methods, you can compare the actual result with the expected result, or to
test if a condition is true or false.
You need to include your Point.java and ExtendedCircle.java files in the same package for this
assignment. Even if you do not make any changes to those two classes, you still need to include
them for this assignment so that your JUnit test program can be tested.
2
To test whether two floating point values are equal using assertEquals method, you will need
another parameter to be used as the threshold for the difference between the two numbers.
Note: Javadoc comments are needed for question 1, but not for question 2.
Submission instructions
You need to submit your programs electronically on Canvas.
Please use a named package for each of your assignment. For example, for assignment 5,
create a new package and name your package as assg5_yourPirateId (use lower case for your
pirate id), such as assg5_smithj21. You also need to include a statement such as “package
assg5_smithj21;” at the beginning of each of your .java file. Please follow this naming
convention exactly for all future assignments. You will be deducted points for not doing so.
When you submit your files to Canvas, please submit a zip file with your package folder
inside the zip file. The package folder should include only .java files (make sure you
include .java files, not .class files). The name of the folder should match with your package
name. (You can use 7-zip software to zip files/folder).