Related questions
Hi... Please check below java code.
Mailbox.java
import java.util.List;
public class Mailbox {
private List<Message> all;
private int numOfMessages;
public List<Message> getAll() {
return all;
}
public void setAll(List<Message> all) {
this.all = all;
}
public int getNumOfMessages() {
return numOfMessages;
}
public void setNumOfMessages(int numOfMessages) {
this.numOfMessages = numOfMessages;
}
public Mailbox(List<Message> all, int numOfMessages) {
super();
this.all = all;
this.numOfMessages = numOfMessages;
}
public Message getMessage(int i){
return all.get(i-1);
}
public void removeMessages(int i){
all.remove(i-1);
}
public void printAllMessages(){
for(Message m:all){
System.out.println(m.getMessage());
}
}
}
Message.java
public class Message {
private String message;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Message(String message) {
super();
this.message = message;
}
}
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- in python. For this project, you will import the json module. Write a class named NobelData that reads a JSON file containing data on Nobel Prizes and allows the user to search that data. Your code does not need to access the internet. Your class should have: an init method that reads the file and stores it in whatever data member(s) you prefer. Any data members of the NobelData class must be private. a method named search_nobel that takes as parameters a year and a category, and returns a sorted list (in normal English dictionary order) of the surnames for the winner(s) in that category for that year (up to three people can share the prize). The year will be a string (e.g. "1975"), not a number. The categories are: "chemistry", "economics", "literature", "peace", "physics", and "medicine". For example, your class could be used like this: nd = NobelData() nd.search_nobel("2001", "economics")arrow_forwardThe first picture is Part 1. Please Write IN java. Please keep code very simple and neat. Dont add anything extra if you aren't instructed to. Be sure to add comments but not long comments. Below is what you will need to implement inside of code. Still read the attachment. MERGE.TXT File: 100921355202224995011059817824503305990763731010642777arrow_forwardBy using the following line, a new instance of the Transcript class will be created.arrow_forward
- When is the Decorator pattern applicable? When an existing operation of an object is restricted When an existing operation is enhanced When new operations need to be added to an object at runtime. All of thesearrow_forwardFor this lab task, you will work with classes and objects. Create a class named text that works similar to the built-in string class. You will need to define a constructor that can be used to initialize objects of this new class with some literal text. Next, define three methods: to_upper() that will convert all characters to uppercase, reverse() that will reverse the text and length() that will return the length of the text. After you have completed this part, copy the following mainfunction to your code and check if the implementation is correct. int main() { text sample = "This is a sample text"; cout << sample.to_upper(); // This should display "THIS IS A SAMPLE TEXT" cout << endl;cout << sample.reverse(); // This should display "txet elpmas a si sihT"cout << endl; cout << sample.length(); // This should display 21 }arrow_forwardFor activities with output like below, your output's whitespace (newlines or spaces) must match exactly. See this note. Write code that outputs variable num_baths as follows. End with a newline. Ex: If the input is 3, then the output is: Baths: 3arrow_forward
- thank you. base on the program above, I want to add one more a method to calcute Mode base on the file. please provide a screenshot of ur program once it's finished.arrow_forward1A. Create a Die class with one integer instance variable called sideUp. Give it a constructor and a getSideUp() method that returns the value of sideUp and a void roll() method that changes sideUp to a random value from 1 to 6. [Note: To generate a random integer between 1 and 6, use Math.random() method] Then create a DieDemo class with a main method that creates two Die objects, rolls them, and then prints the sum of the two sides up.arrow_forwardin python. you will import the json module. Write a class named SatData that reads a JSON file containing data on 2010 SAT results for New York City and writes the data to a text file in CSV format. Your code does not need to access the internet. CSV is a very simple format - just commas separating columns and newlines separating rows (see note below about commas that are part of field names). You'll see an example of CSV format below. There is a csv module for Python, but you will not use it for this project. Your class should have: an init method that reads the file and stores it in whatever data member(s) you prefer. Any data members of the SatData class must be private. a method named save_as_csv that takes as a parameter a list of DBNs (district bureau numbers) and saves a CSV file that looks like this, but with only the rows that correspond to the DBNs in the list (and also the row of column headers). To see what CSV syntax looks like, open the file as a text file rather than as...arrow_forward
- I have tried numerous codes to try to find a solution to this one. I continue to get error codes for the shopping cart. My guess it has something to do with the scanner? Here is the problem and what is pre-loaded into the program: Create a program using classes that does the following in the zyLabs developer below. For this lab, you will be working with two different class files. To switch files, look for where it says "Current File" at the top of the developer window. Click the current file name, then select the file you need.(1) Create two files to submit: ItemToPurchase.java - Class definition ShoppingCartPrinter.java - Contains main() method Build the ItemToPurchase class with the following specifications: Private fields String itemName - Initialized in default constructor to "none" int itemPrice - Initialized in default constructor to 0 int itemQuantity - Initialized in default constructor to 0 Default constructor Public member methods (mutators & accessors)...arrow_forwardIn the Utils class provided to you in this exercise, please fill in the details for a method called swapArray(). You can either upload a file or use the Edit tab to submit your work The VPL tester will pass an arbitrary array of type integer to your method, along with the value of the locations in the array of two values that need to be swapped (exchanged). For instance, in the illustration below, the method swapArray is told to swap the values in positions 0 and 2 of an array made up of (10, 20, 30, 40, 50}. The three input parameters to the method are the array, as well as the two array indices (i and j) that control which elements to swap. public class utils { public static woid wap Array (int[] the Array, int i ,int j){ ex: lo 20 30 40 50 write stuff here Jwaparrow_forwardYou need to execute a call to a void method data.compute(), which may throw a ComputeException. Write a suitable fragment of code which makes a call to this method and: a. if no ComputeException exception is thrown, prints "Computed" on standard output, OR b. if a ComputeException is thrown, prints "Failed to compute". No other output should be printer.arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY