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

*OBJECT ORIENTED PROGRAMMING* JAVA PROGRAMMING GOAL: will be able to throw and catch exceptions and create...
*OBJECT ORIENTED PROGRAMMING* JAVA 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...
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...
Using the various Object Oriented Programming concepts and skills learnt in this course, design and develop...
Using the various Object Oriented Programming concepts and skills learnt in this course, design and develop a Java Application to compute an individual student’s GPA and store the records in a database. The application should have two components i.e. The student and the course components. The following should be the minimal operations on the course component: – Set course information – Print course information – Show credit hours – Show course number The following should be the minimal operations on...
*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....
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),...
-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...
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...
Briefly explain the terms used in object-oriented programming with examples.
Briefly explain the terms used in object-oriented programming with examples.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT