Question

In: Physics

This week, you will create and implement an object-oriented programming design for your project. You will...

This week, you will create and implement an object-oriented programming design for your project. You will learn to identify and describe the classes, their attributes and operations, as well as the relations between the classes. Create class diagrams using Visual Studio. Review the How to: Add class diagrams to projects (Links to an external site.) page from Microsoft’s website; it will tell you how to install it.

Submit a screen shot from Visual Studio with your explanation into a Word document, save as a .docx, before submitting it.

Below is the code I am trying to add class diagrams to:

using System;

namespace ConsoleApp8
{
class Program
{
static void Main(string[] args)
{

// display the current date
DateTime d = DateTime.Now;
Console.WriteLine("{0:dd/MM/yyyy HH:mm:ss}", d);

Console.WriteLine("Quiz");
string[] questions = LoadQuestions();

Boolean[] status = { false, false, false, false, false, false, false, false, false };

string[] options = LoadOptions();

string[] key = { "A", "B", "C", "D", "B", "C", "A", "A", "A" };

int noCorrectAnswer = 0;

// iterate through questions
for (int i = 0; i < 9; i++)
{
string choice = DisplayQA(questions, options, i);

// record correct answers
if (choice == key[i])
{
status[i] = true;
noCorrectAnswer++;
}
}

// if all answers are not correct, restart the quiz for wrong answers
if (noCorrectAnswer < 9)
{
Console.WriteLine("Re-Start Quiz================================");
Console.WriteLine("Repeat the quiz for wrong answered questions!");
for (int i = 0; i < 9; i++)
{
if (status[i] == false)
{
string choice = DisplayQA(questions, options, i);

if (choice.Equals(key[i], StringComparison.OrdinalIgnoreCase))
{
noCorrectAnswer++;
status[i] = true;
}
}
}
}

// display correct answers
Console.WriteLine("Number of correct Answers: " + noCorrectAnswer);
Console.ReadLine();
}

///


/// display question with answer choices
///


///
///
///
///
private static string DisplayQA(string[] questions, string[] options, int i)
{
string choice = "";
Console.WriteLine(questions[i]);
Console.WriteLine(options[i]);

Console.Write("Enter the answer: ");
choice = Console.ReadLine();

// keep asking until user enters valid option
while (!(choice.ToUpper().Equals("A") || choice.ToUpper().Equals("B") || choice.ToUpper().Equals("C") || choice.ToUpper().Equals("D")))
{
Console.WriteLine("\nInvalid value. Please choose valid option!");
Console.Write("Enter the answer: ");
choice = Console.ReadLine();
}

return choice;
}

///


/// Load question options
///


///
private static string[] LoadOptions()
{
return new string[] { "A. 5\nB. 5\nC. 6\nD. 9",
"A. 2\nB. 7\nC. 6\nD. 9"
,"A. 2\nB. 5\nC. 7\nD. 9"
,"A. 2\nB. 5\nC. 6\nD. 24"
,"A. 2\nB. 1440\nC. 6\nD. 9"
,"A. 2\nB. 5\nC. 12\nD. 9"
,"A. 86400\nB. 5\nC. 6\nD. 9"
,"A. 60\nB. 5\nC. 6\nD. 9"
,"A. 60\nB. 5\nC. 6\nD. 9"};
}

///


/// Load Questions
///


///
private static string[] LoadQuestions()
{
string[] questions ={"How many working days are there in a week?"
,"How many systems make up the human body?"
,"How many days are there in a week?"
,"How many hours make up one day?"
,"How many minutes make up one day?"
,"How many months are there in a year?"
,"How many seconds make up one day?"
,"How many seconds make up one hour?"
,"How many minutes make up one hour?"};
return questions;
}
}
}

The prgramming language is C# through Visual Studio. Thanks.

Solutions

Expert Solution

namespace ConsoleApp8
{
class Program
{
static void Main(string[] args)
{

// display the current date
DateTime d = DateTime.Now;
Console.WriteLine("{0:dd/MM/yyyy HH:mm:ss}", d);

Console.WriteLine("Quiz");
string[] questions = LoadQuestions();

Boolean[] status = { false, false, false, false, false, false, false, false, false };

string[] options = LoadOptions();

string[] key = { "A", "B", "C", "D", "B", "C", "A", "A", "A" };

int noCorrectAnswer = 0;

// iterate through questions
for (int i = 0; i < 9; i++)
{
string choice = DisplayQA(questions, options, i);

// record correct answers
if (choice == key[i])
{
status[i] = true;
noCorrectAnswer++;
}
}

// if all answers are not correct, restart the quiz for wrong answers
if (noCorrectAnswer < 9)
{
Console.WriteLine("Re-Start Quiz================================");
Console.WriteLine("Repeat the quiz for wrong answered questions!");
for (int i = 0; i < 9; i++)
{
if (status[i] == false)
{
string choice = DisplayQA(questions, options, i);

if (choice.Equals(key[i], StringComparison.OrdinalIgnoreCase))
{
noCorrectAnswer++;
status[i] = true;
}
}
}
}

// display correct answers
Console.WriteLine("Number of correct Answers: " + noCorrectAnswer);
Console.ReadLine();
}

///


/// display question with answer choices
///


///
///
///
///
private static string DisplayQA(string[] questions, string[] options, int i)
{
string choice = "";
Console.WriteLine(questions[i]);
Console.WriteLine(options[i]);

Console.Write("Enter the answer: ");
choice = Console.ReadLine();

// keep asking until user enters valid option
while (!(choice.ToUpper().Equals("A") || choice.ToUpper().Equals("B") || choice.ToUpper().Equals("C") || choice.ToUpper().Equals("D")))
{
Console.WriteLine("\nInvalid value. Please choose valid option!");
Console.Write("Enter the answer: ");
choice = Console.ReadLine();
}

return choice;
}

///


/// Load question options
///


///
private static string[] LoadOptions()
{
return new string[] { "A. 5\nB. 5\nC. 6\nD. 9",
"A. 2\nB. 7\nC. 6\nD. 9"
,"A. 2\nB. 5\nC. 7\nD. 9"
,"A. 2\nB. 5\nC. 6\nD. 24"
,"A. 2\nB. 1440\nC. 6\nD. 9"
,"A. 2\nB. 5\nC. 12\nD. 9"
,"A. 86400\nB. 5\nC. 6\nD. 9"
,"A. 60\nB. 5\nC. 6\nD. 9"
,"A. 60\nB. 5\nC. 6\nD. 9"};
}

///


/// Load Questions
///


///
private static string[] LoadQuestions()
{
string[] questions ={"How many working days are there in a week?"
,"How many systems make up the human body?"
,"How many days are there in a week?"
,"How many hours make up one day?"
,"How many minutes make up one day?"
,"How many months are there in a year?"
,"How many seconds make up one day?"
,"How many seconds make up one hour?"
,"How many minutes make up one hour?"};
return questions;
}
}
}


Related Solutions

Kindly Do the program in C++ language Object Oriented Programming. Objectives  Implement a simple class...
Kindly Do the program in C++ language Object Oriented Programming. Objectives  Implement a simple class with public and private members and multiple constructors.  Gain a better understanding of the building and using of classes and objects.  Practice problem solving using OOP. Overview You will implement a date and day of week calculator for the SELECTED calendar year. The calculator repeatedly reads in three numbers from the standard input that are interpreted as month, day of month, days...
*OBJECT ORIENTED PROGRAMMING* GOAL: will be able to throw and catch exceptions and create multi-threaded programs....
*OBJECT ORIENTED PROGRAMMING* GOAL: will be able to throw and catch exceptions and create multi-threaded programs. Part I Create a class called Animal that implements the Runnable interface. In the main method create 2 instances of the Animal class, one called rabbit and one called turtle. Make them "user" threads, as opposed to daemon threads. Some detail about the Animal class. It has instance variables, name, position, speed, and restMax. It has a static boolean winner. It starts a false....
-What is object-oriented programming? -What is a class? -What is an object? -A contractor uses a...
-What is object-oriented programming? -What is a class? -What is an object? -A contractor uses a blueprint to build a set of identical houses. Are classes analogous to the blueprint or the houses? Explain. -What is a class diagram? How is it used in object-oriented programming? -What is an attribute in OOP? What is a data member? -What is a method in OOP? What is a member function? -What is the difference between private members and public members of a...
In this assignment, you will practice solving a problem using object-oriented programming and specifically, you will...
In this assignment, you will practice solving a problem using object-oriented programming and specifically, you will use the concept of object aggregation (i.e., has-a relationship between objects). You will implement a Java application, called MovieApplication that could be used in the movie industry. You are asked to implement three classes: Movie, Distributor, and MovieDriver. Each of these classes is described below. The Movie class represents a movie and has the following attributes: name (of type String), directorsName (of type String),...
Research and explain in your words what is known as Object Oriented Programming. Then, identify two...
Research and explain in your words what is known as Object Oriented Programming. Then, identify two advantages of OOP for application development. In peer replies, choose from one of the following and define the concept as part of your response. Abstraction. Encapsulation. Inheritance. Polymorphism.
object oriented programming java Create a Student class that have two data members id (assign to...
object oriented programming java Create a Student class that have two data members id (assign to your ID) and name (assign to your name). Create the object of the Student class by new keyword and printing the objects value. You may name your object as Student1. The output should be like this: 20170500 Asma Zubaida
Object-Oriented Design and Patterns in Java (the 3rd Edition Chapter 5) - Create a directory named...
Object-Oriented Design and Patterns in Java (the 3rd Edition Chapter 5) - Create a directory named as the question number and save the required solutions in the directory. - Each problem comes with an expected tester name. In the directory for a given problem, including the tester and all java classes successfully run this tester. Exercise 5.2 ObserverTester.java - Improve Exercise 1 by making the graph view editable. Attach a mouse listener to the panel that paints the graph. When...
Throughout this course, you will be learning about object-oriented programming and demonstrating what you learn by...
Throughout this course, you will be learning about object-oriented programming and demonstrating what you learn by writing some programs in Java. The first step will be to install and integrated development environment (IDE) that will be where you will write and compile your programs. You will also write your first program using Java to show that you have correctly installed the IDE. The project instructions and deliverables are as follows: Download and install Java JDK and NetBeans IDE using the...
PHP You will be using the object oriented features of PHP to design a music album...
PHP You will be using the object oriented features of PHP to design a music album processing page. First you will build a form page called addAlbum.php. This form will contain text fields for album title, artist, publisher (Sony, BMI, etc.) and genre. Add two more fields of your choice. You will post this form to the file process.php. If all the fields have values, we will create a new Album object and print the details of the object. You...
1. In Object Oriented Programming The private object fields can be directly manipulated by outside entities....
1. In Object Oriented Programming The private object fields can be directly manipulated by outside entities. Group of answer choices A. True B. False 2. __________ programming is centered on the procedures or actions that take place in a program. Group of answer choices A. Class B. Object-oriented C. Menu-driven D. Procedural/ Structural 3. __________ programming encapsulates data and functions in an object. Group of answer choices A. Object-oriented B. Class C. Menu-driven D. Procedural 4. The data in an...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT