1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kryger [21]
4 years ago
6

Create a Flash Card class. Flash Cards have a Question and an Answer, each of which are Strings. Your class should include a con

structor, toString() and equals() methods. Write a main() method that creates an array of three Flash Cards, and prints each of them.
Computers and Technology
1 answer:
xeze [42]4 years ago
6 0

Answer:

<u> FlashCard.java</u>

  1. public class FlashCard {
  2.    String Question;
  3.    String Answer;
  4.    public FlashCard(String q, String a){
  5.        this.Question = q;
  6.        this.Answer = a;
  7.    }
  8.    public String toString(){
  9.        String output = "";
  10.        output += "Question: " + this.Question + "\n";
  11.        output += "Answer: " + this.Answer;
  12.        return output;
  13.    }
  14.    public boolean equals(String response){
  15.        if(this.Answer.equals(response)){
  16.            return true;
  17.        }
  18.        else{
  19.            return false;
  20.        }
  21.    }
  22. }

<u>Main.java</u>

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        FlashCard card1 = new FlashCard("What is highest mountain?", "Everest");
  4.        FlashCard card2 = new FlashCard("What is natural satelite of earth?", "Moon");
  5.        FlashCard card3 = new FlashCard("Who is the first president of US?", "George Washington");
  6.        FlashCard cards [] = {card1, card2, card3};
  7.        for(int i=0; i < cards.length; i++){
  8.            System.out.println(cards[i]);
  9.        }
  10.    }
  11. }

Explanation:

In FlashCard.java, we create a FlashCard class with two instance variable, Question and Answer (Line 2 - 3). There is a constructor that takes two input strings to initialize the Question and Answer instance variables (Line 5-8). There is also a toString method that will return the predefined output string of question answer (Line 10 - 15). And also another equals method that will take an input string and check against with the Answer using string equals method. If matched, return True (Line 17 -24).

In Main.java, create three FlashCard object (Line 3-5) and then put them into an array (Line 6). Use a for loop to print the object (Line 8-10). The sample output is as follows:

Question: What is highest mountain?

Answer: Everest

Question: What is natural satelite of earth?

Answer: Moon

Question: Who is the first president of US?

Answer: George Washington

You might be interested in
The client-server network at Scoops, a chain of ice cream stores, currently depends on one server machine running Windows Server
sp2606 [1]

The most common advantage of using Linux servers as opposed to the Windows servers is that Linux servers are open source while Windows servers are not. They are not available for free and must be purchased through licensing. With that being said, let us get into the similarities and differences

File sharing: They both use protocols like FTP to transfer and share files. However, Thanks to Window’s server GUI and repositories like Group Policy Object (GPO), this server is convenient when sharing files. Winner: Windows Server

Remote Access – Windows server will take this one too. The fact that it has an intuitive GUI, remote desktop access will be considered a better solution to use in windows than in Linux. Linux requires a command-line terminal to run commands, and this can sometimes be difficult to use. You will also need to configure several other things to make remote access work. Winner: Windows

Mail service capabilities – Both can run mail servers, and both are effective in mail service capabilities. Therefore, none wins on this. Winner: Draw.

Ease of use – I have mentioned this several times that Windows has a GUI that makes work easier for admins and techies. It is easier to configure a lot of things in Windows than it is in Linux. The former is GUI while the latter is command-line based. GUI is always great. It is always easier to use a complete Graphical User Interface that has more features like bells and notifications than it is in Linux.  Winner: Windows

Reliability and support – Linux is based on Unix. Unix was built to be reliable and very powerful. Some people might have different opinions on this, but Linux remains reliable in things like configurations and security implementations. Linux servers have an awesome network community of support. Issues found within these platforms can be seen really quickly and can get fixes within hours. Windows has excellent support as well, but this will come at a cost.

Winner: Linux

It depends on what is needed in the organization. If possible, I would suggest that they use both platforms. They should not isolate them. If that option is not feasible, I would suggest they continue using what they have as their main server. They, however, need to upgrade to a more recent Windows server like 2012. In as much as Windows has won in the comparisons above, Linux has stepped up in trying to offer GUI. We need to understand that making decisions between these two platforms needs one to understand the advantages and disadvantages of both and how they fit in. The manager might have heard a lot of good things about Linux servers and especially Fedora, but Windows has a lot of good things too.

7 0
3 years ago
What does SIP stand for?
agasfer [191]
Session Initiation Protocol, brainliest ?
4 0
4 years ago
Read 2 more answers
1.3 Code Practice edhisive
almond37 [142]

Answer:

edhesive

Explanation:

4 0
3 years ago
When video files are played while being downloaded from the internet, it is called _____?
garri49 [273]
The answer is Video Streaming.  This is so when video files are played while being downloaded from the internet.  <span>Video streaming is a type of media streaming in which the data from a video file is continuously delivered via the Internet to a remote user. It allows a video to be viewed online while being downloaded on a host computer or device.</span>
3 0
3 years ago
Soothing musical CDs that contain imperceptible messages designed to help people eat more fruits and vegetables is an example of
Katena32 [7]
It is an example of <span>subliminal stimulation</span>
6 0
3 years ago
Read 2 more answers
Other questions:
  • What is a possible style of formatting your company could prefer?
    14·2 answers
  • Why wont my brainly account rank up even tho i have 1193 points and 5/5 brainly trophies but it still wont rank me up to vistro
    11·2 answers
  • Which data type requires the greatest number of bytes in computer memory? A. character B. integer C. single-precision number D.
    14·1 answer
  • The default page orientation in a microsoft excel worksheet is landscape true false
    13·1 answer
  • What is 8 hours, 5 minutes, 22 seconds minus (-) 7 hours, 24 minutes, 37 seconds?
    6·1 answer
  • In 1913, __________ developed a mass production system for cars that made it possible to produce more cars in a shorter period o
    5·2 answers
  • What is the iterative procedure of recursive and nonrecursive?
    10·1 answer
  • What is an OS? Explain the objectives of an OS.​
    11·1 answer
  • List 10 ways how can graphic design help the community
    13·1 answer
  • Select the four tactics that cyber criminals use for stealing information from the list below.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!