What do the following terms mean in the context of software development?
a. Portability b. Interoperability c. Maintainability d. Robustness
In: Computer Science
write a c# program that:
The file is using a very simple form of compression in which
there are no spaces, each word is separated by camel casing. For
Example, the string "TheCatWillRun" is parsed as "The Cat Will
Run".
*Now for the statistics*
Prints to the console the following statistics about the content in
the file retrieved above.
- How many of each letter are in the file
- How many letters are capitalized in the file
- The most common word and the number of times it has been
seen.
- The most common 2 character prefix and the number of occurrences
in the text file.
In: Computer Science
1. Create a flow chart from the algorithm then create python code.
Algorithm: Tell the user to enter their name, how many cars the user has, and the average number of cars per family in the users state. Create a variable to show the difference between the users number of cars and the average number of cars per family. Print the values of name, number of cars, average number of cars, and the difference in 2 decimal places.
In: Computer Science
java
CLASS DESIGN GUIDELINES
1. Cohesion • [✓] A class should describe a single entity, and all the class operations should logically fit together to support a coherent purpose. • [✓] A single entity with many responsibilities can be broken into several classes to separate the responsibilities.
2. Consistency • [✓] Follow standard Java programming style and naming conventions. Choose informative names for classes, data fields, and methods. A popular style is to place the data declaration before the constructor and place constructors before methods. • [✓] Make the names consistent. It is not a good practice to choose different names for similar operations. • [✓] In general, you should consistently provide a public no-arg constructor for constructing a default instance. If a class does not support a no-arg constructor, document the reason. If no constructors are defined explicitly, a public default no-arg constructor with an empty body is assumed. • [✓] If you want to prevent users from creating an object for a class, you can declare a private constructor in the class, as is the case for the Math class.
3. Encapsulation • [✓] A class should use the private modifier to hide its data from direct access by clients. This makes the class easy to maintain. • [✓] Provide a getter method only if you want the data field to be readable, and provide a setter method only if you want the data field to be updateable.
4. Clarity • [✓] Cohesion, consistency, and encapsulation are good guidelines for achieving design clarity. Additionally, a class should have a clear contract that is easy to explain and easy to understand. • [✓] Users can incorporate classes in many different combinations, orders, and environments. Therefore, you should design a class that imposes no restrictions on how or when the user can use it, design the properties in a way that lets the user set them in any order and with any combination of values, and design methods that function independently of their order of occurrence. • [✓] Methods should be defined intuitively without causing confusion. • [✓] You should not declare a data field that can be derived from other data fields.
5. Completeness • [✓] Classes are designed for use by many different customers. In order to be useful in a wide range of applications, a class should provide a variety of ways for customization through properties and methods.
6. Instance vs. Static • [✓] A variable or method that is dependent on a specific instance of the class must be an instance variable or method. A variable that is shared by all the instances of a class should be declared static. • [✓] Always reference static variables and methods from a class name (rather than a reference variable) to improve readability and avoid errors. • [✓] Do not pass a parameter from a constructor to initialize a static data field. It is better to use a setter method to change the static data field. • [✓] Instance and static are integral parts of object-oriented programming. A data field or method is either instance or static. Do not mistakenly overlook static data fields or methods. It is a common design error to define an instance method should have been static. • [✓] A constructor is always instance, because it is used to create a specific instance. A static variable or method can be invoked from an instance method, but an instance variable or method cannot be invoked from a static method.
7. Inheritance vs. Aggregation • [✓] The difference between inheritance and aggregation is the difference between an is-a and a has-a relationship.
8. Interfaces vs. Abstract Classes • [✓] Both interfaces and abstract classes can be used to specify common behavior for objects. How do you decide whether to use an interface or a class? In general, a strong is-a relationship that clearly describes a parentchild relationship should be modeled using classes. A weak is-a relationship, also known as an is-kind-of relationship, indicates that an object possesses a certain property. A weak is-a relationship can modeled using interfaces. • [✓] Interfaces are more flexible than abstract classes, because a subclass can extend only one superclass but can implement any number of interfaces. However, interfaces cannot contain concrete methods. The virtues of interfaces and abstract classes can be combined by creating an interface with an abstract class that implement it. Then you can use the interface or the abstract class, whichever is convenient.
Please choose 5 guidelines and discuss them in depth. For each guideline, use at least half a page for your discussion.
In: Computer Science
JAVA: Lab11C:Behaviors.In the context of OOP, functions are called methods or behaviors because they typically do something. Most often, they read or change the values of one or more variables in the class. For example, you may have a weight variable in a class, and a method called gainWeight( ) that increases the weight variable by a certain amount.
For this part of the lab, create class KoalaBear that has a weightattribute(in kilograms). Create a constructor for the class that takes in (as a parameter) the initial weight of the koala bear. Then, write a function called eat( ) that takes in the number of leaves the koala bear should eat. Each leaf weighs one gram, so you must increase the weight of the koala bear by one gram. According to a site dedicated to saving Koala bears, they can eat between 200-500 grams of leaves per day. To finish the class out, include a showWeight() method that prints out how much the koala weighs.
In main, create a koala object starting at 100 kilos and show the koala’s weight. Then, make the koala eat 400, 300, and 650 leaves, showing the weight of the koala after each time it eats.
NOTE: if you’re output does not match exactly (because of the rounding of floating point math), that’s OK. For example, Java will include some extra “precision”.
Sample output #1
This koala weighs 100.4 kilos
This koala weighs 100.7 kilos
This koala weighs 101.35 kilos
In: Computer Science
Using Java please implement a 4x4 Tic-Tac-Toe with Minimax with alpha-beta pruning. Please comment code heavily so I can follow along and understand the steps. Also, inlcude a screenshot of the final output. Do not include code for GUI, a GUI is not needed. Thank you
In: Computer Science
C++
Create a recursive program what will test three recursive functions. It would have a menu like:
1. Recursive factorial
2. Towers of Hanoi
3. Recursive summation
0. Exit
Enter selection: 3
Enter number: 4
The recursive summation will take an integer and sum value from 1 to the integer. Don’t enter a number if the selection is 0 for quit. Please have the functions in an implementation file and the prototypes of the functions in a header file and the main in a separate file.
In: Computer Science
Java Question:
Which of the following statements about the reference super is true?
|
|||
|
|||
|
|||
|
In: Computer Science
C# ( asp.net ) 2019 Visual Studio
I have a dropdown where you can select ( integer, string, date )
After selecting the desired dropdown option, user can input a list of inputs. For example; for integer: 2,5,7,9,1,3,4
And then , I have a 'sort' button
Can you please help me with the code behind for sorting them( For integer, string, and date )
Thank you.
In: Computer Science
What countermeasures can be adopted to mitigate SYN flood attacks?
In: Computer Science
Python Question
Using lists, write the function non_unique(list) that takes a
list list as argument. It
returns a list which duplicated elements remains and each
duplicated element is followed by
a number which shows how many times it appears. All elements in
return list should be in
the same order as their appearance in the original list.
For example, given the input [‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘d’,
‘a’,‘e’], the function
would return [‘a’, 3, ‘b’, 2]. Another example, ['abc', 'def',
'abc', 'xyz', 'def','def', 'qwe'] -> ['abc', 2, 'def', 3]
If no such non_unique list exist, just return an empty list.
Your program should contain the function with format shown as
below:
def non_unique(list):
# Your codes here
return result # ‘result’ is a list.
In: Computer Science
Locate your Student project from the previous in-class assignment. You will add a new class to that project.
1. Create a class called Course. It should have a field to hold an ArrayList of Student objects.
2. Create a constructor for Course that accepts an ArrayList of Student objects, and set field to the parameter.
3. In the Course class, create a method called addStudent(Student s). This should add the parameter "s" to the ArrayList of Student objects.
4. In the Course class, create a method called removeStudent(Student s). This method should remove the parameter"s" from the ArrayList of Student objects.
5. In the Course class, create a method called toString(). This method should return a String showing the information from all the Student objects in the ArrayList. It should be formatted in the following way:
"Student 0: *Student 0 toString()*
Student 1: *Student 1 toString()*
...
Student n: *Student n toString()*"
This method should call each Student object's toString() method, as shown in the above example.
MY CODE :
student.java
package student;
public class Student {
public static void main(String[] args) {
Course myNewCourse = new Course(2) ;
System.out.println(myNewCourse.toString());
}
private int idNum;
private String firstN;
private String lastN;
public Student(int studentId, String firstName, String lastName ){
idNum = studentId;
firstN = firstName;
lastN = lastName;
}
public String toString(){
String allData = "Student"+"1"+":ID: "+getIdNum()+ ", First name:
"
+ getFirstName()+ ", Last name: " +getLastName()+ "." ;
return allData;
}
public void setIdNum(int studentId){
this.idNum = studentId;
}
public void setFirstName(String firstName){
this.firstN = firstName;
}
public void setLastName(String lastName){
this.lastN = lastName;
}
public int getIdNum(){
return idNum;
}
public String getFirstName(){
return firstN;
}
public String getLastName() {
return lastN;
}
}
course.java
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package student;
import java.util.ArrayList;
/**
*
* @author farha
*/
public class Course {
ArrayList<Student> students = new
ArrayList<Student>();
public Course(ArrayList<Student> students){
this.students = students;
}
public void addStudent(Student s){
students.add(0, s);
}
public void removeStudent(Student s){
students.remove(s);
}
public String toString(){
String information = ("");
return information;
}
}
In: Computer Science
My recursive Tower of Hanoi program does not render the correct index numbers. Also, it does not prompt user to enter the starting rod letter and the ending rod letter. Could you help me fix it?
Main.java
import java.io.*;
import java.util.List;
import java.util.Scanner;
public class Main {
int index = 1;
public static void main(String[] args) {
/**There is a stack of N disks on the first of three poles (call them A, B and C) and your job is to move the disks from pole A to pole B without
ever putting a larger disk on top of a smaller disk.*/
System.out.println();
System.out.println("Tower of Hanoi");
System.out.println("Program by Quang Pham");
System.out.println();
char startingrod = ' ';
char endingrod = ' ';
Scanner sc = new Scanner(System.in);
System.out.println("Enter the starting rod letter (A, B, or C).");
startingrod = sc.next().charAt(0);
System.out.println("Enter the ending rod letter (A, B, C).");
endingrod = sc.next().charAt(0);
if (startingrod == endingrod)
{
System.out.println("Sorry. Starting rod and ending rod cannot be the same.");
System.out.println("Enter ending rod letter (A, B, C)");
endingrod = sc.next().charAt(0);
}
if (startingrod == 'A' && endingrod =='C')
{
System.out.println("OK. Starting with discs 1, 2, 3, on rod A \n");
System.out.println("Moves are:");
int count = playHanoi (3,"A","B","C");
System.out.println();
System.out.println("All done.");
System.out.println("Took a total of " + count + " moves.");
System.out.println();
}
}
private static int playHanoi( int n, String from , String other, String to)
{ int count = 1;
//int index = 1;
if (n == 0)
return 0;
else if(n == 1)
{
System.out.printf("%d." + " Move disk "+ n +" from rod %s to rod %s \n", count, from, to);
//index++;
return count;
}
else{
count+= playHanoi(n-1, from, to, other);
System.out.printf("%d." + " Move disk " + n + " from rod %s to rod %s \n ", count, from, to);
count+=playHanoi(n-1, other, from, to);
}
//
return count;
}
}
The directions are:
Tower of Hanoi Program by YOUR NAME Enter Starting Rod (A, B, or C): A Enter Ending Rod (A, B, or C): A Sorry. starting and ending rod cannot be the same. Enter Ending Rod ((A, B, or C): C OK Starting with discs 1, 2, and 3 on rod A Moves are as follows: 1. Move disc 1 from rod A to rod C 2. Move disc 2 from rod A to rod B 3. Move disc 1 from rod C to rod B 4. Move disc. 3 from rod A to rod C 5. Move disk 1 from rod B to rod A 6. Move disk 2 from rod B to rod C 7. Move disk 1 from rod A to rod C All done. Took a total of 7 moves.
Any help with this program is greatly appreciated. Yours truly, Quang Pham
In: Computer Science
Why is anonymity different in TWN and WLAN?
explain the 802.11 shared-key authentication process
In: Computer Science
For practice using exceptions, this exercise will use a try/catch block to validate integer input from a user. Write a brief program to test the user input. Use a try/catch block, request user entry of an integer, use Scanner to read the input, throw an InputMismatchException if the input is not valid, and display "This is an invalid entry, please enter an integer" when an exception is thrown. InputMismatchException is one of the existing Java exceptions thrown by the Scanner if the input does not match the type requested.
In: Computer Science