Please implement Sample string toString()method for each class and return itself a string, not the output. import java.util.ArrayList; public class Customer extends User{ private ArrayList orders; public Customer(String display_name, String password, String email) { super(display_name, password, email); } @Override public String getPermissionLevel() { return "CUSTOMER"; } public void addOrder(Order order){ this.orders.add(order); } public ArrayList listOrders(){ return this.orders; }; }
----------------
public class ElectronicProduct extends Product{ private long SNo; private String warranty_period; public ElectronicProduct(long SNo, String warranty_period, String productId, String productName, String brandName, String Description) { super(productId, productName, brandName, Description); this.SNo = SNo; this.warranty_period = warranty_period; } }
--------------
public class HomeProduct extends Product{ String location; public HomeProduct(String location, String productId, String productName, String brandName, String Description) { super(productId, productName, brandName, Description); this.location = location; } }
----------------------
import java.util.ArrayList; import java.util.Date; public class Order { private int order_no; private ArrayList products; private String order_Status; private Date final_date; public Order(int order_no, String order_Status, Date final_date) { this.order_no = order_no; this.order_Status = order_Status; this.final_date = final_date; this.products = new ArrayList<>(); } public Date getFinal_date() { return final_date; } public String getOrder_Status() { return order_Status; } public int getOrder_no() { return order_no; } public void setFinal_date(Date final_date) { this.final_date = final_date; } public void setOrder_Status(String order_Status) { this.order_Status = order_Status; } public void setOrder_no(int order_no) { this.order_no = order_no; } public ArrayList getProducts(){ return this.products; } public void addProduct(Product product){ this.products.add(product); } }
------------------------------------------------
import java.time.LocalDate; import java.util.ArrayList; import java.util.Date; public class Product { private String productId; private String productName; private String brandName; private String description; private ArrayList categories; private LocalDate dateCatalog; public Product(String productId, String productName, String brandName, String description) { this.productId = productId; this.productName = productName; this.brandName = brandName; this.description = description; this.dateCatalog = LocalDate.now(); this.categories = new ArrayList<>(); } public String getProductId() { return productId; } public String getDescription() { return description; } public String getProductName() { return productName; } public void addCategory(Category category){ this.categories.add(category); } public ArrayList listCategories(){ return this.categories; } }
--------
-----------------------------------------
In: Computer Science
Colonial Adventure Tours Case
In: Computer Science
Need SQL commands for these questions based on the bowling league database; When was the first tournament date and where was it played? What are the number of tournaments per location?
In: Computer Science
In: Computer Science
In python Using the example code from the HangMan program in our textbook, create a Word Guessing Game of your choice. Design a guessing game of your own creation. Choose a theme and build your words around that theme. Keep it simple.
Note: I would highly recommend closely reviewing the HangMan code and program from Chapter 10 before starting work on this project. You can run the program via my REPL (Links to an external site.).
Using python Similar to our Number Guessing game, be sure to allow the player the option to keep playing and keep score. You can design the game however you see fit but it must meet these requirements:
General Requirements
Word lists
Output in python test and paste code
Guesses in python code show
Think the program through
Break this down into smaller sized concepts first. Walk through the program functions step by step. Here is some of my thought processes to get you started. Thank you for helping me
import wordlist
# Get a random word from the word list
def get_word():
word = wordlist.get_random_word()
return word.upper()
# Add spaces between letters
def add_spaces(word):
word_with_spaces = " ".join(word)
return word_with_spaces
# Draw the display
def draw_screen(num_wrong, num_guesses, guessed_letters,
displayed_word):
print("-" * 79)
print("Word:", add_spaces(displayed_word),
" Guesses:", num_guesses,
" Wrong:", num_wrong,
" Tried:", add_spaces(guessed_letters))
# Get next letter from user
def get_letter(guessed_letters):
while True:
guess = input("Enter a letter: ").strip().upper()
# Make sure the user enters a letter and only one letter
if guess == "" or len(guess) > 1:
print("Invalid entry. " +
"Please enter one and only one letter.")
continue
# Don't let the user try the same letter more than once
elif guess in guessed_letters:
print("You already tried that letter.")
continue
else:
return guess
# The input/process/draw technique is common in game
programming
def play_game():
word = get_word()
word_length = len(word)
remaining_letters = word_length
displayed_word = "_" * word_length
num_wrong = 0
num_guesses = 0
guessed_letters = ""
draw_screen(num_wrong, num_guesses, guessed_letters, displayed_word)
while num_wrong < 10 and remaining_letters > 0:
guess = get_letter(guessed_letters)
guessed_letters += guess
pos = word.find(guess, 0)
if pos != -1:
displayed_word = ""
remaining_letters = word_length
for char in word:
if char in guessed_letters:
displayed_word += char
remaining_letters -= 1
else:
displayed_word += "_"
else:
num_wrong += 1
num_guesses += 1
draw_screen(num_wrong, num_guesses, guessed_letters, displayed_word)
print("-" * 79)
if remaining_letters == 0:
print("Congratulations! You got it in",
num_guesses, "guesses.")
else:
print("Sorry, you lost.")
print("The word was:", word)
def main():
print("Play the H A N G M A N game")
while True:
play_game()
print()
again = input("Do you want to play again (y/n)?: ").lower()
if again != "y":
break
if __name__ == "__main__":
main()
In: Computer Science
Quiz for Cartography
1. Which map element (e.g., LASTDOG + PADS) documents the overall
purpose of a map?
(a) Legend (b) Author (c)Scale (d) Title (e) Date (f) Orientation
(g) Grid
(h) Map Projection (i) Positional Accuracy (j) Geodetic Datum (k)
Data Sources
2. Which map elements (e.g., LASTDOG + PADS) are missing from
Google Maps?
(a) Legend (b) Author (c)Scale (d) Title (e) Date (f) Orientation
(g) Grid
(h) Map Projection (i) Positional Accuracy (j) Geodetic Datum (k)
Data Sources
3. Which is true about a given point P (e.g., Mount Everest) on the
surface of Earth?
(a) P has a unique (latitude, longitude).
(b) Given a map projection (e.g., Mercator), P has a unique
(latitude, longitude).
(c) Given a geodetic datum, P has a unique (latitude,
longitude).
(d) Given a time and a geodetic datum, P has a unique (latitude,
longitude).
(e) Latitude and longitude for P vary over 100m across different
Geodetic datum
(f) Major earthquakes may change Latitude and longitude for P by
several meters
4. Which is true about the North determined by a (stationary)
compass (or a compass app)?
(a) Away from poles, it points towards the North Star (Polaris) in
the sky.
(b) Away from poles, it points towards the true north (direction
along a longitude towards the geographic North Pole).
(c) Away from poles, it points towards the magnetic (north)
pole.
(d) At magnetic pole, it points towards the true north.
(e) At geographic North Pole, it points towards the magnetic
pole.
5. Which spatial relationships are preserved by a topological map,
e.g., sub-way maps?
(a) connectivity between stations via train lines
(b) distances between stations along train lines
(c) absolute geographic direction (e.g., north, east) between
stations
(d) relative direction between stations along train lines
6. Choropleth maps show statistical data aggregated over previously
defined regions (e.g.,
states, countries). In contrast, Isarithmic maps define
region
boundaries based on data. Divide the following maps into either
Choropleth or Isarithmic:
(a) Topographic maps showing iso-elevation contours
(b) Census maps
(c) Election Map to convey results of an Election
(d) Weather forecast maps showing areas of sunshine, clouds, rain,
snow, ...
(e) Accessibility map showing commute time to a city center
(f) Hotspot map showing elliptical regions of unusually high
density of disease (or crime)
(f) Google map app showing a phone's location as a standard
deviation circle around a mean point (center point)
7. Which font properties are used in text labels to denote fluid
nature of water bodies?
(a) Serif fonts (a) San Serif fonts (c) Italics (d) Blue
color
8. Which is not a common characteristic of a well-designed
cartographic map?
(a) clarity and legibility (b) order (c) beauty (d) realism
(d) balance (e) Unity and Harmony (f) visual hierarchy (g) visual
contrast
9. Match colors to map layers in common maps:
(a) Colors are black, blue, brown, green, red, yellow
(b) Map layers include arid areas, forests, mountains, place names,
sea surface temperature, water
10. Consider a map for wind energy farm development. Classify the
following map layers into
foreground and background for this map: country boundaries, roads,
lakes, place names, transmission lines, wind-mills.
In: Computer Science
For this assignment, you will apply what you learned in analyzing Java™ code so far in this course by writing your own Java™ program. The Java™ program you write should do the following:
Complete this assignment by doing the following:
Program Summary: This program demonstrates these basic Java
concepts:
* - defining variables of different types
* - if-then and if-then-else logic
* - constructing a string to display onscreen
* - switch logic
*
* To complete this assignment, you will add code where indicated.
The
* behavior of your completed assignment should be to accept an
input
* value for the number of sides of a two-dimensional figure. Based
on that value,
* your code should display the type of figure that corresponds to
the number of polygon angles
* indicated (3=triangle, 4=rectangle, etc.)
*
* Here are the specific requirements:
*
* After the user types in a value from 3 to 5 inclusive (i.e., 3,
4, or 5):
*
* 1. Your code determines whether the input value is out of range
(less than 3 or more than 5)
* and, if so, displays a meaningful error message on the screen and
ends the program.
*
* 2. Because you will be comparing a single expression (the input
value) to multiple constants (3, 4, and 5),
* your code should use a switch statement to display the following
message onscreen:
*
* If user inputs 3, onscreen message should say "A triangle has 3
sides."
* If user inputs 4, onscreen message should say "A rectangle has 4
sides."
* If user inputs 5, onscreen message should see "A pentagon has 5
sides."
*
* 3. Be sure to test your program. This means running your program
multiple
* times with test values 3, 4, 5, as well as at least two values
that fall outside that range
* (one lower than the lowest and one higher than the highest) and
making sure
* that the correct message displays for each value you input. Also
be sure
* that running your program does not cause any compiler
errors.
***********************************************************************/
package week2codingassignment;
import java.util.Scanner;
public class PRG420Week2_CodingAssignment {
public static void main(String[] args) {
String userInputStringOfAngles; // Declare a variable of type
String to capture user input
int numberOfAngles; // Declare a variable of type int to hold the
converted user input
Scanner myInputScannerInstance = new Scanner(System.in); //
Recognize the keyboard
System.out.print("Please type the integer 3, 4, or 5 and then press
Enter: "); // Prompt the user
userInputStringOfAngles= myInputScannerInstance.next(); // Capture
user input as string
numberOfAngles = Integer.parseInt(userInputStringOfAngles); //
Convert the string to a number in case this will be useful
later
// LINE 1. CODE TO DETERMINE WHETHER USER INPUT IS OUT OF BOUNDS
GOES HERE
// LINE 2. SWITCH CODE TO PRINT CORRECT "SHAPE" MESSAGE BASED ON
USER INPUT GOES HERE
}
}
In: Computer Science
Information. in java Consider a banking system with 3 classes: BankAccount, CheckingAccount, and SavingsAccount, that you are to design and write. Have CheckingAccount and SavingsAccount inherit from BankAccount. In BankAccount, you should include an account number, an account balance, a deposit method, a toString method, and an abstract withdraw method. Since deposits work the same way in both child classes, make sure they cannot override it. The constructor should only take an initial deposit and generate a random 5 digit account number. The toString should display the account number and the balance.
In the CheckingAccount class add a minimum balance and a standard overdraft fee of $25. Implement the withdraw method so that overdrafts are allowed, but the overdraft fee is incurred if the balance drops below the minimum balance. Override the toString method to display everything the BankAccount toString displays plus the minimum balance. Use the parent class toString to do most of the work.
In the SavingsAccount class add an annual interest rate (with a default value of 1.5%) and a method to recalculate the balance every month. Since the interest rate is annual, make sure to calculate the interest accordingly. Override the toString method to display everything the BankAccount toString displays plus the interest rate. Like the CheckingAccount toString, you should use the parent class to do most of the work.
question. Write the Java implementation of the SavingsAccount. Note: no driver is required.
In: Computer Science
Building a Prime Factorization Factory
It is common, and smart, in computing to build upon work that you or others have done previously, rather than re-inventing the wheel. In this project, you will build on some functions defined in the class slides and in the book. Of course, in this class you should never use work that you find on the internet or done by anyone other than youself, except as specifically allowed, as in this case!
Many of the examples we've done in class have involved dealing with prime numbers: decide whether a number is a prime, find the next prime, print the first 100 primes, etc. The concept of a prime number is fundamental in mathematics, particularly in number theory. In fact, the fundamental theorem of arithmetic states that every positive integer (greater than 1) can be represented uniquely (order doesn't matter) as a product of one or more primes. Your task in this project is to write a library of functions to deal with primes including finding the prime factorization of arbitrary positive integers.
Assignment:
When the program begins it should print the message ``Welcome to the Prime factory!'' Then, accept from the user a command, which can be one of the following: factor, isprime, or end. Case does not matter for this command. Example: end, EnD, and END should all behave identically. (You don't have to preserve the case of the input string in error messages.) If the user enters anything else, print an error message. See the examples below.
If the user enters factor, prompt for an integer greater than 1. You can assume that the input is an integer, but don't assume it is greater than 1. If it's not, print an error message and return to the top level loop (i.e., back to prompting for a command). If an integer greater than 1 is entered, compute and print its prime factorization as a list. See the examples below.
If the user enters isprime, prompt for an integer. You can assume that the input is an integer. If the supplied value is less than 2, print an error message and return to the top level loop. Otherwise, check whether the input is prime and print an appropriate message. See the examples below.
Finally, if the user enters end, print the message ``Thanks for using our service!'' and exit.
Put a blank line between each round of interaction to make the output more readible.
Expected Output:
Below is some sample output for this program. You should match this exactly.
> python Project2.py Welcome to the Prime factory! Enter a command (factor, isprime, end): fector Command fector not recognized. Try again! Enter a command (factor, isprime, end): fAcToR Enter an integer > 1: 1000 The prime factorization of 1000 is: [2, 2, 2, 5, 5, 5] Enter a command (factor, isprime, end): facTOR Enter an integer > 1: 213 The prime factorization of 213 is: [3, 71] Enter a command (factor, isprime, end): factor Enter an integer > 1: -23 Illegal input: -23; input must be an integer > 1. Enter a command (factor, isprime, end): factor 100 Command factor 100 not recognized. Try again! Enter a command (factor, isprime, end): factor Enter an integer > 1: 1009 The prime factorization of 1009 is: [1009] Enter a command (factor, isprime, end): isPRIME Enter an integer > 1: 1009 The number 1009 is prime Enter a command (factor, isprime, end): ISprime 213 Command isprime 213 not recognized. Try again! Enter a command (factor, isprime, end): ISprime Enter an integer > 1: 213 The number 213 is not prime Enter a command (factor, isprime, end): IsPrime Enter an integer > 1: -23 Illegal input: -23; input must be an integer > 1. Enter a command (factor, isprime, end): isPrime? Command isprime? not recognized. Try again! Enter a command (factor, isprime, end): EnD Thanks for using our service! Goodbye. >
In: Computer Science
What is the difference between IP and MAC address on a PC? What command would you type that will give you both IP and MAC information.
In: Computer Science
1) Given an array queue implementation with one unused entry and frontIndex and backIndex references, match the status of the queue with the following information about frontIndex and backIndex for a queue with capacity of 5:
a.) frontIndex is 0 and backIndex is 4
b.) frontIndex is 1 and backIndex is 4
c.) frontIndex is 3 and backIndex is 0
empty queue
one element in the queue
three elements in the queue
four elements in the queue
five elements in the queue
six elements in the queue
invalid
Please Help!
In: Computer Science
We saw that Quicksort actually won’t be “quick” when it attempts to sort some types of inputs (e.g., it will take O(n2) time to sort n numbers that are already sorted). List two different ways to improve Quicksort so that it will run “quickly” (on average, in linear time) regardless of the characteristics of the input pattern.
In: Computer Science
2. Write a c++ program that takes from the user the number of courses and constructs 3 dynamic 1D arrays with size courses+1. Each array represents a student. Each cell in the array represents a student’s mark in a course. In the last cell of each 1D array you should calculate the average mark of that student. Then output the average mark of all students in each course. Delete any allocated memory. Example Number of courses : 4 50 60 70 20 100 90 80 70 80 90 100 30 Output: 50 60 70 20 50 100 90 80 70 85 80 90 100 30 75 Avg of course 1 = 76.66 Avg of course 2 = 80 Avg of course 3 = 83.33 Avg of course 4 = 40.
In: Computer Science
Information:
Consider a banking system with 3 classes: BankAccount, CheckingAccount, and SavingsAccount, that you are to design and write. Have CheckingAccount and SavingsAccount inherit from BankAccount. In BankAccount, you should include an account number, an account balance, a deposit method, a toString method, and an abstract withdraw method. Since deposits work the same way in both child classes, make sure they cannot override it. The constructor should only take an initial deposit and generate a random 5 digit account number. The toString should display the account number and the balance.
In the CheckingAccount class add a minimum balance and a standard overdraft fee of $25. Implement the withdraw method so that overdrafts are allowed, but the overdraft fee is incurred if the balance drops below the minimum balance. Override the toString method to display everything the BankAccount toString displays plus the minimum balance. Use the parent class toString to do most of the work.
In the SavingsAccount class add an annual interest rate (with a default value of 1.5%) and a method to recalculate the balance every month. Since the interest rate is annual, make sure to calculate the interest accordingly. Override the toString method to display everything the BankAccount toString displays plus the interest rate. Like the CheckingAccount toString, you should use the parent class to do most of the work.
Question: Write the Java implementation of the BankAccount. Note, no driver is required.
In: Computer Science
I am new to socket programming and I wish to know what these
lines of code do. I know they are creating UDP sockets, but it
would help if someone explained what the code means. Thank
you.
Python Code:
import socket
testingSocket = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)
testingSocket.setsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR,
testingSocket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST,
1)
testingSocket.bind(('0.0.0.0', 50000))
send_socket = socket.socket(socket.AF_INET,
socket.SOCK_DGRAM)
send_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST,
1)
receiving_thread = Thread(target=self.receivingFunction)
send_thread = Thread(target=self.sendMessage)
broadcast_online_status_thread = Thread(target=onlineStatus)
In: Computer Science