* Word file clearly describe the test suite (series of test cases) you design for each of the methods in TestWithJUnit.java (one test suite per method). Each test suite should contain at least 5 test cases. Each test case has to be justified: Why did you pick this test case and not another one? Imagine you are limited by time and money about the number of test cases you can pick and run. Why would you make run the test cases you propose? You have to be convincing. In particular, you have to address: WHAT each test case aims to test, and HOW you expect the method to run on this test case (what output do you expect?).
*In a new java file, that you will call TestWithJUnitTester.java, write a JUnit test for each of the test cases you have described in your word file.
* Run your test cases and report the results in your word document. In particular, you have to report whether the method behaves as expected or not on each test case, and propose an explanation in case the method does not behave as expected.
Note: your test cases cannot include the examples given within the code.
Advice: when designing test cases, think:
1/ regular functionality test: does the code perform as expected under normal/expected circumstances?
2/ edge case: does the code still perform when under stress of its expected conditions?
You need to have at least one of the first type (maybe two depending on how complex the code is), and 3 or 4 of the second type.
public class TestWithJUnit {
/* Method withoutTen:
* Return a version of the given array where all
* the 10's have been removed.
* The remaining elements should shift left
* towards the start of the array as needed,
* and the empty spaces a the end of the array
* should be 0.
* So {1, 10, 10, 2} yields {1, 2, 0, 0}.
* {1, 10, 10, 2, 10, 3, 10} yields {1, 2, 3, 0, 0, 0,
0}.
*/
public int[] withoutTen(int[] A) {
int[] result = new
int[A.length];
int index = 0;
for (int i = 0; i < A.length;
i++) {
if (A[i] != 10)
{
result[index] = A[i];
index++;
}
}
for (int i = index; i <
result.length; i++)
result[i] =
0;
return result;
}
/* Method bigArray:
* Given an integer n, bigArray creates and returns a
1D array
* that contains {1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2,
... n}
* For instance, bigArray(4) = {1, 1, 2, 1, 2, 3, 1, 2,
3, 4}
* bigArray(2) = {1, 1, 2}
*/
public int[] bigArray(int n) {
int[] result = new
int[n*(n+1)/2];
int index = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 1;
j <= i; j++) {
result[index] = j;
index++;
}
}
return result;
}
}
In: Computer Science
there are only three roles in a scrum team. In your opinion, what might be some team responsibilities that are not covered in any of these roles? Could you see yourself becoming a scrum master? Why or why not
In: Computer Science
Question 1
A local online trading company, Bursa Malaysia (BSKL) is running out of capacity and performance with the current storage system. BSKL has decided to own a RAID system at a reasonable cost to increase the speed, capacity, availability and scalability of the trading activities.
(a) Identify any FIVE (5) RAID systems that might be suitable for BSKL. (Refer to the BSKL website to understand the online activities that have been actively running.)
[10 marks]
In: Computer Science
(Python Programming)
You are asked to develop a cash register for a fruit shop that sells oranges and apples. The program will first ask the number of customers. Subsequently, for each customer, it will ask the name of the customer and the number of oranges and apples they would like to buy. And then print a summary of what they bought along with the bill as illustrated in the session below:
How many customers? 2 Name of Customer 1 Harry Oranges are $1.40 each. How many Oranges? 1 Apples are $.75 each. How many Apples? 2 Harry, you bought 1 Orange(s) and 2 Apple(s). Your bill is $2.9 Name of Customer 2 Sandy Oranges are $1.40 each. How many Oranges? 10 Apples are $.75 each. How many Apples? 4 Sandy, you bought 10 Orange(s) and 4 Apple(s). Your bill is $17.0
In: Computer Science
Exercise 1:
Write an XML document describing the exercises in this document: the root element is <exercises>. The root has an attribute number that has value 1. The root element has three child elements; <date> that contains as text the date of the exercise, and two <item> elements for the first two exercises (1--2). Write some text in the <item> elements.
Exercise 2:
Write an XML document describing a person: name, occupation, address and hobbies. Please do not use your own information, you can use fake data. Decide on suitable element names and nesting. Check your document for well-formedness.
Exercise 3:
Draw a tree that represents the XML document you created in task 2.
Exercise 4:
This is the books.xml file
<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory
database -->
<bookstore>
<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
<title>The Autobiography of Benjamin
Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
<title>The Gorgias</title>
<author>
<name>Plato</name>
</author>
<price>9.99</price>
</book>
</bookstore>
Using books.xml as a model, create a small xml file for a student's
program of study form called programOfStudy.xml. It should capture
the following data:
In: Computer Science
Project: Use SMTP to send an email
1. Start a connection
2. Say hello to the server
helo networking
3. Login request
auth login
4. Input username
For example,
Plaintext: networkingtest2018
BASE64: bmV0d29ya2luZ3Rlc3QyMDE4
5. Input password
BASE64: Your passwordxxxxxx
after inputting your password, you will see
means you have already logged in.
6. Input sender and receiver’s information
, which
Note that go to https://www.base64decode.org/ to find the
encoded BASE64 phrase of your username and password.
7. Start drafting your email by typing data
8. Write your email
Subject:Hello
xxx
xxx
.
9. Finish writing your email and send.
If you want to finish writing, enter an enter to have a new line and input a dot.
10. Log out by inputting a quit
In: Computer Science
Describe in detail the encryption and decryption process for Simplified DES by showing your results at each step Details of decryption process:
input: 10 bit key = 1 1 1 1 1 1 1 1 1 1 and 8 bit plaintext = 0 0 0 0 0 0 0 0
Output from IP =
Output from first Fk using K2 =
Output from SW =
Output from first Fk using K1 =
Output from IP-1 =
In: Computer Science
Python 3 Program
Program 4 should first tell users that this is a word analysis software. For any user-given text file, the program will read, analyze, and write each word with the line numbers where the word is found in an output file. A word may appear in multiple lines. A word shows more than once at a line, the line number will be only recorded one time.
Ask a user to enter the name of a text file. Using try/except for invalid user input. Then the program reads the contents of the text file and create a dictionary in which the key-value pairs are described as follows:
Key. The key are the individual words found in the file.
Value. Each value is a list that contains the line numbers in the file where the word (the key) is found. Be aware that a list may have only one element.
Once the dictionary has been built, the program should create another text file for otuput, named “words_index.txt”. Next, write the contents of the dictionary to the file as an alphabetical listing of the words that are stored as keys in the dictionary (sorting the keys), along with the line numbers where the words appear in the original file. Please see the sample file for your reference.
Looking to seeing everyone to submit a well-done program! Here are some tips:
Documents/Comments of your program (Never more)
Testing your program by the given two files, Kennedy.txt . The output file of the Kennedy_index.txt, Kennedy_index_B.txt, Kennedy_index_C.txt, for input file “kennedy.txt”
Remember the output file name of your program is words_index.txt.
For this program, not running one (syntax error) will receive NO point.
Example of original text- Kennedy.txt
We observe today not a victory of party but a celebration of freedom symbolizing an end as well as a beginning signifying renewal as well as change
New text example - Kennedy_index.txt
Text File to be analyzed: Kennedy.txt We: 1 a: 1, 2, 4 an: 3 as: 4, 5, 6 beginning: 4 but: 2 celebration: 2 change: 6 end: 3 freedom: 3 not: 1 observe: 1 of: 2, 3 party: 2 renewal: 5 signifying: 5 symbolizing: 3 today: 1 victory: 1 well: 4, 5
example- Kenndy_index_B.txt
Text File to be analyzed: kennedy.txt We : 1 a : 1, 2, 4 an : 3 as : 4, 5, 6 beginning : 4 but : 2 celebration : 2 change : 6 end : 3 freedom : 3 not : 1 observe : 1 of : 2, 3 party : 2 renewal : 5 signifying : 5 symbolizing : 3 today : 1 victory : 1 well : 4, 5
example- Kenndy_index_C.txt
Text File to be analyzed: kennedy.txt We : 1 a : 1, 2, 4 an : 3 as : 4, 5, 6 beginning : 4 but : 2 celebration : 2 change : 6 end : 3 freedom : 3 not : 1 observe : 1 of : 2, 3 party : 2 renewal : 5 signifying : 5 symbolizing : 3 today : 1 victory : 1 well : 4, 5
In: Computer Science
Shell script program that asks a number between 5 to 9. If the input is not between 5 and 9, display an error message and ask again.
Output
1
22
333
4444
55555
666666
7777777
88888888
999999999
In: Computer Science
Draw an ER diagram containing the ConferenceSeries, the ConferenceEvent, and the ConferenceTrack entitysets where each ConferenceSeries can be linked to zero or many ConferenceEvent entities, and each Conference Event may be linked to one or many ConferenceTracks. ConferenceTrack should not exists without a ConferenceEvent. Choose an appropriate relationship name. Then augment the model with an entityset Venue and a relationship named OrganizedAt associating each ConferenceEvent with exactly one Venue. Assume that a Venue must have run at least one ConferenceEvent. Your ER diagram should show all details. Show a translation into tables for a SQL database (topic covered in class on Tue Sept 9). Note: Add 3 attributes to each of the entity type with appropriate primary key.
In: Computer Science
does a zombie process use CPU time true or false
and is it true or false that a orphan process will find a new parent and will not use CPU time.
In: Computer Science
Show the encoding of the following machine instructions and convert into hexadecimal.
1. STUR X7, [X9, #32]
2. SUBI X16, X4, #52
3. AND X5, X20, X3
In: Computer Science
This code is an expression of cp command in c language. But I don't understand this code very well. Please explain in notes one by one.(in detail)
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
#include<errno.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
int main(int argc, char *argv[])
{
char ch;
int src, dst;
struct stat st;
if(argc != 3)
{
printf("argument error \n");
printf("usage: ./a.out src dest \n");
exit(0);
}
if (stat(argv[1], &st) == -1) {
perror("stat : ");
exit(-1);
}
src = open(argv[1], O_RDONLY);
if(src == -1){
perror("open source");
exit(errno);
}
dst = open(argv[2], O_WRONLY | O_CREAT|O_TRUNC);
if(dst == -1){
perror("open source");
exit(errno);
}
while(read(src, &ch,1)){
write(dst,&ch,1);
}
close(src);
close(dst);
if (chmod(argv[2], st.st_mode)) {
perror("chmod : ");
return -1;
}
return 0;
}
In: Computer Science
I need to make changes to code following the steps below. The code that needs to be modified is below the steps. Thank you.
1. Refactor Base Weapon class:
a. Remove the Weapon abstract class and create a new Interface class named WeaponInterface.
b. Add a public method fireWeapon() that returns void and takes no arguments.
c. Add a public method fireWeapon() that returns void and takes a power argument as an integer type.
d. Add a public method activate() that returns void and takes an argument as an boolean type.
2. Refactor the specialization Weapon Classes:
a. Refactor the Bomb class so that it implements the WeaponInterface class.
b. Refactor the Gun class so that that it implements the WeaponInterface class.
3. Refactor the Game Class:
a. Remove all existing game logic in main().
b. Create a private helper method fireWeapon() that takes a WeaponInterface as an argument as a weapon. For the passed in weapon activate the weapon then fire the weapon.
c. Create an array of type WeaponInterface that can hold 2 weapons.
d. Initialize the first array element with a Bomb.
e. Initialize the second array element with a Gun.
f. Loop over the weapons array and call displayArea() for each weapon.
------
// Weapon.java
public abstract class Weapon {
public void fireWeapon(int power)
{
System.out.println("Class Name
:"+this.getClass().getSimpleName());
System.out.println("Mathod Name
:"+new Throwable().getStackTrace()[0].getMethodName());
System.out.println("Power
:"+power);
}
public abstract void activate(boolean enable);
}
______________________
// Bomb.java
public class Bomb extends Weapon {
@Override
public void fireWeapon(int power)
{
System.out.println("Class Name
:"+this.getClass().getSimpleName());
System.out.println("Mathod Name
:"+new Throwable().getStackTrace()[0].getMethodName());
System.out.println("Power
:"+power);
}
public void fireWeapon()
{
System.out.println("Class Name
:"+this.getClass().getSimpleName());
System.out.println("Mathod Name
:"+new Throwable().getStackTrace()[0].getMethodName());
super.fireWeapon(67);
}
@Override
public void activate(boolean enable) {
System.out.println("Class Name
:"+this.getClass().getSimpleName());
System.out.println("Mathod Name
:"+new Throwable().getStackTrace()[0].getMethodName());
System.out.println("Enable
:"+enable);
}
}
_____________________________
// Gun.java
public class Gun extends Weapon {
@Override
public void fireWeapon(int power)
{
System.out.println("Class Name
:"+this.getClass().getSimpleName());
System.out.println("Mathod Name
:"+new Throwable().getStackTrace()[0].getMethodName());
System.out.println("Power
:"+power);
}
public void fireWeapon()
{
System.out.println("Class Name
:"+this.getClass().getSimpleName());
System.out.println("Mathod Name
:"+new Throwable().getStackTrace()[0].getMethodName());
super.fireWeapon(98);
}
@Override
public void activate(boolean enable) {
System.out.println("Class Name
:"+this.getClass().getSimpleName());
System.out.println("Mathod Name
:"+new Throwable().getStackTrace()[0].getMethodName());
System.out.println("Enable
:"+enable);
}
}
_____________________________
// Game.java
public class Game {
public static void main(String args[]) {
Bomb b = new Bomb();
Gun g = new Gun();
b.fireWeapon(45);
g.fireWeapon(60);
}
}
In: Computer Science
Explain how to use the C# shortcut arithmetic operators -=, *=, and /=.
In: Computer Science