Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MVC Design One principle often used in software design is separation of concerns. Modules should depend on one another as little a possible to do

MVC Design

One principle often used in software design is "separation of concerns". Modules should depend on one another as little a possible to do the job they are given.

This can be seen in a common programming pattern used to design graphical applications: the Model-View-Controller (MVC) pattern.

https://en.wikipedia.org/wiki/Model-view-controller

In an MVC design, the View module is concerned with presenting a graphical view of the application to the user. The Model is concerned with maintaining a valid representation of the current state of the application, and the Controller is responsible for receiving instructions from the user. Java does not do anything to enforce these roles, as with all design patterns, MVC is simply a set of guidelines that help a software designer make decisions about how to decompose a program into smaller, simpler parts. By separating the MVC concerns, each module has a clear role and each can be programmed and tested independently.

You will learn more about design patterns if you take CSC 133, but for now just know that I used one to help me decide how to break SimpleBot into smaller logical parts.

Overview of Project 3

This part of the project will provide the main program for your SimpleBot interpreter. Running SimpleBotMain should prompt the user for two files (a world file and a SimpleBot program file), then it should hook each file to a Scanner and pass the Scanners to a SimpleBotController. If the SimpleBotController successfully reads the two files, the SimpleBotController should be asked to start the simulation.

SimpleBotMain

Write a static main method in a class called SimpleBotMain. Your main should first prompt for the name of a SimpleBot program file. Once it has a valid file name, your main should prompt for the name of a SimpleBot world file. Each time the user types in a file that does not exist or types in a file that does exist but results in an error when read by the SimpleBotController, your main should immediately report the error and give the user a chance to try the file name again. Once the files have been read and the Scanners have been accepted by SimpleBotController, a message should be issued that the simulation is starting, and SimpleBotController's start method should be called. Here's an example interaction:

Program file name: foo.txt Error. That file does not exists. Program file name: bar.txt Error. That file did not load properly. Program file name: prog.txt World file name: foo.txt Error. That file does not exists. World file name: bar.txt Error. That file did not load properly. World file name: world.txt Starting simulation... 

Note that prompting for the program file and prompting for the world file are identical operations except that prompts differ slightly. You should write a private helper method that takes a prompt as a parameter and returns a Scanner. The method should repeatedly prompt the user until it is is able to open the user response as a file and connect a Scanner to it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

What were the reasons for your conversion or resistance?

Answered: 1 week ago

Question

1. Who should participate and how will participants be recruited?

Answered: 1 week ago