Build a class called “Animal” which has three attributes: “ArrayList<String> diet”, “int numOfLegs”, and “Boolean carnivore”. Build a constructor with three parameters to set the three attributes. In the constructor, if the number of legs given in the parameter is below 0 set the number of legs equal to 0. Add seven methods:
Now that we have a base class, we’re going to make a subclass of our “Animal” class. Make a class called “Cat” that is a subclass of “Animal”. In “Cat” add a new attribute “String color”. Build a constructor with two parameters, an arrayList<String> diet and String color, in the new constructor call the superClass’s constructor and assume the number of legs of all cats is 4 and every cat is a carnivore. Add a method “String getColor()” that returns the cat’s color. Replace (override) the original “makeSound()” method with a new “makeSound()” function that returns the string “Meow”.
In: Computer Science
IP Mask Gateway
S1 192.168.1.1 255.255.255.192 192.168.1.62
PC2 192.168.2.1 255.255.255.192 192.168.2.62
PC1 192.168.3.1 255.255.255.192 192.168.3.62
In: Computer Science
Hi had a question I am trying to develop this iOS app in Xcode in Swift language and getting hung up on this Rock Paper Scissors game on the bottom is my code when it comes to paper and rock rock wins when it comes to rock and scissors scissors wins other than that it works ok . please help thanks !
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var leftblankview: UIImageView!
@IBOutlet weak var rightblankview: UIImageView!
@IBOutlet weak var leftscorelabel: UILabel!
@IBOutlet weak var rightscorelabel: UILabel!
var leftScore = 0
var rightScore = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func buttonclick(_ sender: Any) {
let leftNumber = Int.random(in: 1...3)
let rightNumber = Int.random(in: 1...3)
leftblankview.image = UIImage(named: "symbol\(leftNumber)")
rightblankview.image = UIImage(named: "symbol\(rightNumber)")
if leftNumber > rightNumber {
leftScore += 1
leftscorelabel.text = String(leftScore)
}
else if leftNumber < rightNumber{
rightScore += 1
rightscorelabel.text = String(rightScore)
}
else{
}
}
}
In: Computer Science
language is Java
Design a super class Person with the fields for holding a person's name, address, and phone number. Code at least two overloaded constructors and the appropriate mutator and accessor methods. Next, design a subclass Customer that inherits from the Person class. In addition to inherit all data and methods from its super class, the Customer class should have a field for a customer ID and a boolean field indicating whether or not the customer whishes to be on a mailing list. Code appropriate constructors, mutator and accessor methods for added fields in Customer class.
Then code a driver class InheritanceApp to test the classes by creating at least one object for Person class and at least one object for Customer class to display all field information using overridden toString(), respectively. You my do hard- coded data in test.
Must code Person and Customer classes as your operation classes with the inheritance relationship and then InheritanceApp as the driver. Run and test your code to meet the requirements.
Must understand the purpose of using inheritance in coding and how well you perform the code-reuseability.
Must create at least one object for each class (Person and Customer).
Must use required/meaningful names for fields, methods and doc each of your source codes.
In: Computer Science
In: Computer Science
List and explain five EIGRP commands that can be used at the command line to support EIGRP on a router. Include any relevant parameters of the command that can benefit the network engineer supporting the router
In: Computer Science
Create an Interface DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount for the purchase of a given number of a single item. The method has two parameters, count (int type) and itemCost (double type). Create a class BulkDiscount that implements Interface DiscountPolicy. The BulkDiscount class has two proprieties: theMinimum (int type), and percent (double type). It should have a constructor that sets the parameters, minimum and percent to a given values. It should define the method computeDiscount so that if the quantity (count) purchased of an item is more than minimum, the discount is calculated as count*itemCost*percentOff/100.0, otherwise, discount will be equal=0.0; Write a test program that tests your method. Create at least three objects of BulkDiscount class and print out their discount values. (JAVA)
In: Computer Science
1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 40
In: Computer Science
Write a program that asks the user for 10 integers, then prints all integers, followed by the largest integer.
CPP. ONLY!!
In: Computer Science
This is C++. I would like to know the TODO list comments.
#include <cstdlib>
#include <iostream>
// TODO: 2. (1 point) Declare your Acker function prototype
below:
// When done, commit with the commit message that follows,
being
// sure to delete all these TODO instructions before
actuallly
// executing the git commit command.
//
// CSC232-HW02 - Added Aker function prototype.
//
// Don't forget to fully document the function prototype
using
// all the appropriate doxygen elements.
/**
* @brief Entry point to this application.
* @remark You are encouraged to modify this file as you see fit to
gain
* practice in using objects.
*
* @param argc the number of command line arguments
* @param argv an array of the command line arguments
* @return EXIT_SUCCESS upon successful completion
*/
int main(int argc, char **argv) {
// TODO: 4. (0.5 points) Replace *** text ***
with actual call to Acker
// function. When done, commit with the commit
message that follows,
// being sure to delete all these TODO
instructions before actuallly
// executing the git commit command.
//
// CSC232-HW02 - Display calculated Acker
value.
//
std::cout << "Acker(1, 2) = " <<
"*** replace me with call to Acker***"
<<
std::endl;
return EXIT_SUCCESS;
}
// TODO: 3. (2 points) Define the Acker recursive function below.
When done,
// commit with the commit message that follows, being sure to
delete
// all these TODO instructions before actually executing the
git
// commit command.
//
// CSC232-HW02 - Implemented Acker function.
// TODO: 5. (1 point) Do a box trace of Acker(1, 2) using pen and
paper.
// Hand this in at the beginning of class on Friday, 17 February
2017.
// Your solution MUST be legible; no points are assigned to
illegible
// papers.
This is testRunner.
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/Test.h>
#include <cppunit/TestFailure.h>
#include <cppunit/portability/Stream.h>
/**
* @brief Main test driver for CPPUNIT test suite.
* @remark DO NOT MODIFY THE SPECIFICATION OR IMPLEMENTATION OF THIS
CLASS! ANY
* MODIFICATION TO THIS CLASS WILL RESULT IN A GRADE OF 0 FOR THIS
LAB!
*/
class ProgressListener : public CPPUNIT_NS::TestListener {
public:
ProgressListener()
: m_lastTestFailed(false) {
}
~ProgressListener() {
}
void startTest(CPPUNIT_NS::Test *test) {
CPPUNIT_NS::stdCOut()<< test->getName();
CPPUNIT_NS::stdCOut()<< "\n";
CPPUNIT_NS::stdCOut().flush();
m_lastTestFailed =
false;
}
void addFailure(const
CPPUNIT_NS::TestFailure& failure) {
CPPUNIT_NS::stdCOut()<< " : " << (failure.isError() ?
"error" : "assertion");
m_lastTestFailed =
true;
}
void endTest(CPPUNIT_NS::Test *test) {
if
(!m_lastTestFailed)
CPPUNIT_NS::stdCOut() << " : OK";
CPPUNIT_NS::stdCOut()<< "\n";
}
private:
/// Prevents the use of the copy
constructor.
ProgressListener(const ProgressListener&
copy);
/// Prevents the use of the copy operator.
void operator=(const ProgressListener&
copy);
private:
bool m_lastTestFailed;
};
int main() {
// Create the event manager and test
controller
CPPUNIT_NS::TestResult controller;
// Add a listener that colllects test
result
CPPUNIT_NS::TestResultCollector result;
controller.addListener(&result);
// Add a listener that print dots as test
run.
ProgressListener progress;
controller.addListener(&progress);
// Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
runner.run(controller);
// Print test in a compiler compatible
format.
CPPUNIT_NS::CompilerOutputter
outputter(&result, CPPUNIT_NS::stdCOut());
outputter.write();
return result.wasSuccessful() ? 0 : 1;
}
In: Computer Science
What kinds of systems might be valuable targets in information warfare? Create a prioritized list of targets and describe the kinds of damage that could result if these systems were attacked. Provide a minimum of 3 paragraphs.
In: Computer Science
pseudocode
display "Please enter first name: " input fName display "Please enter middle initial (Enter space if none): " input mName display "Please enter last name: " input lName display "Enter hours worked: " input hours display "Enter hourly rate: " input perHourRate weeklySalary = hours * perHourRate output "fName mName. lName" output weeklySalary
Question 1. Move your algorithm/pseudocode/outline into Code:Blocks and create a "shell" program. (The shell program shouldn't do any of the final work, but it should have comments where the final code will go and should compile and run.)
In: Computer Science
If you were designing sound for a game, in what instances would you create your own sounds using foley (or by recording sounds from the environment) versus utilizing pre-existing material from a library? Similarly, when would you create (or hire someone to create) original music versus licensing pre-existing material from a library or label?
In: Computer Science
In C Sharp with the use of the Try and Catch method create an application that displays the contents of the Teams.txt file in a ListBox control. When the user selects a team in the ListBox, the application should display the number of times the team has won the World Series in the time period from 1903 through 2012.
Teams.txt--This file contains a list of several Major League baseball teams in alphabetical order. Each team listed in the file has won the World Series at least once.
WorldSeriesWinners.txt - This file contains a chronological list of the World Series' winning teams from 1903 through 2012. (The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2012. Note that the World Series was not played in 1904 or 1994.)
Hint: Read the contents of the WorldSeriesWinners.text file into a List. When the user selects a team in the ListBox, the application should display the number of times the selected team appears.
In: Computer Science
Java program code: InventoryManager
For this assignment, you will be creating an inventory manager for a store that sells vegetables. The inventory will be managed using arrays.
The required name for the project is
InventoryManager.
The required name for the Java file is
InventoryManager.java.
The required main class name is
InventoryManager.
Part 1: Planning the store
Decide the name of your store. Place this name in a constant
called STORE_NAME.
As soon as the program starts, display a greeting to the user to
let them that they have begun using the inventory management app
for this store.
Then, perform the following:
The following table is just one example of the values that might populate the three arrays. Each index represents one single item.
| INDEX | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| items array | onion | broccoli | carrot | zucchini | cucumber |
| quantities array | 12 | 4 | 3 | 56 | 30 |
| prices array | 1.52 | 0.53 | 1.25 | 1.34 | 2.32 |
NOTE: Apart from the items array, these are just example
values. Because the user is required to enter these values, values
in quantities and prices could be
anything.
If we were to determine the quantity of our carrots, we would first find that "carrot" is located at index 2 in items, so we would retrieve the value in quantities at index 2, which is a quantity of 3. To find the price, we would retrieve the value at index 2 of prices, which is 1.25.
Make sure you use the appropriate datatype for each array (int? double? String?)
All of the previous directions take place only at the beginning of the program. You can think of it as the set up for the main part of the program. Once done, the user will be taken into Part 2 of this assignment.
Part 2: Operating the InventoryManager
Display to the user the possible operations on the inventory and prompt him/her to choose one. The user should select the option by entering its number. Every time the user completes one of the operations (except for Exit), the user should be taken back to this screen where they can choose from this list again. If Exit is selected, the user should be given a message thanking them for using the program, and then the program should be properly closed. Do not use System.exit() to close the program. You must exit the program by exiting the loop itself.
There are 5 possible operations:
1. Print inventory
2. Check for low inventory
3. Highest and lowest inventory value items
4. Total inventory value
5. Exit
1. Print inventory
This operation prints all the inventory items, with each item shown in the following format:
Item: ITEM-NAME
Quantity: ITEM-QUANTITY
Price: ITEM-PRICE
Total value: TOTAL-VALUE
ITEM-NAME should be replaced by the name of the
item.
ITEM-PRICE should be replaced by the price of the
item.
TOTAL-VALUE should be replaced by the total price
if someone were to purchase the entire stock of items.
Make sure your output appears exactly like the format above. You should print the information for all five items in an efficient way (using a loop).
Once this is done, the user should be allowed to select one of the five options from the original menu.
2. Check for low inventory
This operation checks for items that have a quantity of less than 5, then prints them in the same format as in option 1.
If there is no such item whose quantity is less than 5, then display a message that explains that to the user.
Once this is done, the user should be allowed to select one of the five options from the original menu.
3. Highest and lowest inventory value items
This operation finds the following two items:
Remember that the total inventory value is the value of the whole stock of the inventory item combined, which would be equal to the quantity multiplied by the price.
If two or more items have a matching inventory value and they are either the highest or lowest, then you only need to display one of them.
Display the highest and lowest inventory value items in the same way as option 1.
Once this is done, the user should be allowed to select one of the five options from the original menu.
4. Total inventory value
This is the total value of ALL items in the store, taking into account the quantity of each item. Display this value to the user.
Once this is done, the user should be allowed to select one of the five options from the original menu.
5. Exit
If selected, the user should be given a message thanking them for using the program, and then the program should exit. Do not use System.exit() to exit the program. You must exit the program by logically ending the loop.
Requirements
When this program runs, it should be obvious to the user the values they are seeing. Include all units when displaying values. For example, when displaying dollar values, make sure you include a dollar sign ($). You do not need to worry about making two decimal digits show when displaying dollar values. For example, it's okay to display $4.5 instead of $4.50.
In: Computer Science