Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming Assignment Introduction to the Assignment: Life is short and truth lives long: let us speak the truth. -Arthur Schopenhauer, The World as Will

Java Programming Assignment

Introduction to the Assignment:

Life is short and truth lives long: let us speak the truth. -Arthur Schopenhauer, The World as Will and Representation

Arthur Schopenhauer is considered a pessimist. It stands to reason, since one of the key tenets of his moral philosophy is that life consists of pain, and what we call "pleasure" is simply a cessation of that pain. He also thought that the universe was fundamentally unknowable; it consists of a blind urge to exist, known as the Will. The Will has no greater meaning or goal, but endlessly and ceaselessly churns and begets more existence. It exists only in order to exist.

What we see with our eyes, feel with our hands, and hear with our ears is merely the result of our self interacting with the Will. This mixture of perception and Will is Representation. When we see a flower, we don't actually smell it - our eyes simply interact with some minuscule part of the greater Will, and our mind understands our eyes' reactions, not the flower itself. We delude ourselves when we think that we can ever truly understand the flower.

In this lab, we will make a semi-unknowable, higher-dimensional Universe, and a Scientist who will attempt to understand it without being able to perceive our random, meaningless machinations.

Setup:

You will be creating three Java files, Lab09.java, Scientist.java, and World.java.

Assignment Instructions:

Your Lab09 class will create a World, and a Scientist who can travel through the World examining the color of the World at that point. The colors are Lime, Cerulean, Goldenrod, and Black. So far, this is much like our World, but with one key difference - whereas our world exists in three dimensions, this World exists in five! So besides the traditional three directions of movement (up/down, left/right, and forward/back), the Scientist has two other ones (moving "forward" or "backward" in the fourth dimension is known as ana/kata; let's call moving in the fifth dimension grumble/antigrumble).

You will create a five-dimensional, 10x10x10x10x10 unit world, represented by an appropriate multi-dimensional array of ints. At each location, the color is represented by a value from 0 to 9. A value of 1 represents the color Lime, a value of 2, Cerulean, and a value of 3, Goldenrod. All other values represent Black. Colors are determined by the addition of the values of all the coordinates, modulo 10. For example, at position [ 0 1 2 7 3 ], the color is Goldenrod, because 0 + 1 + 2 + 7 + 3 = 13, and 13 % 10 is 3. At position [ 8 0 0 0 8 ], the color is Black, because 8 + 0 + 0 + 0 + 8 = 16, and 16 % 10 is 6, which equates to Black. These colors are meaningless. The algorithm is meaningless. Everything in our constructed world is entirely devoid of meaning.

The World is what is known as Misner space - by heading past one "end" of it, you immediately show up at the "beginning". Imagine a video game where your character goes off the right side of the screen, and immediately shows up on the left side. Similarly, if you are in, for example, location [ 0 0 0 9 0], and move one unit in a positive direction in the fourth dimension, you will end up at [ 0 0 0 0 0 ]. If you now move -5 units in the first dimension, you will end up at [ 5 0 0 0 0 ]. The world "wraps around" itself.

The Scientist constructor accepts a World, and has only one public method, move(). The Scientist starts at position [ 0 0 0 0 0 ]. The scientist can move in any one of the five dimensions, labeled by number - note that the first dimension is 1, the second 2, etc. At each point, the program should display the current location as well as its color. It should then allow the Scientist to continue travelling on their quest.

Every time the scientist stops in a room, it will be painted white. This is how the Scientist knows which rooms have already been entered. Thus, if you come back to a room again, it should always be white. This only applies to rooms that have been stopped in (that is, have been directly traveled to) - not rooms that the Scientist merely walked through to get from one room to another. For example, if the Scientist moves five rooms up, only the final room will be painted white (after displaying its original color, of course). White can be indicated by any number which will not result from the original coloring algorithm (which, remember, returns results modulo 10).

The move method signature should look like this:

 public int[] move(int dimension, int numUnits) 

It will return a six-element array. The first five elements are the dimensional positions (e.g., [ 0 1 2 3 4 ]). The last element is the integer value of the world at that space. However, you will display the color as a String ("Black", "Goldenrod", etc.) You can do this easily with a special String getColor(int value) method which returns the String name of the color based on the argument passed in.

The Scientist will continue to search until a negative dimension is entered as input, at which point the program will stop execution.

Sample Output:

Enter dimension to travel (1,2,3,4,5) (negative to quit) > 1 Enter units to travel (negative for backwards) > 1 Location: [1 0 0 0 0] = Lime Enter dimension to travel (1,2,3,4,5) (negative to quit) > 1 Enter units to travel (negative for backwards) > 1 Location: [2 0 0 0 0] = Cerulean Enter dimension to travel (1,2,3,4,5) (negative to quit) > 1 Enter units to travel (negative for backwards) > -1 Location: [1 0 0 0 0] = White Enter dimension to travel (1,2,3,4,5) (negative to quit) > 2 Enter units to travel (negative for backwards) > 3 Location: [1 3 0 0 0] = Black Enter dimension to travel (1,2,3,4,5) (negative to quit) > 3 Enter units to travel (negative for backwards) > 2 Location: [1 3 2 0 0] = Black Enter dimension to travel (1,2,3,4,5) (negative to quit) > 4 Enter units to travel (negative for backwards) > -15 Location: [1 3 2 5 0] = Lime Enter dimension to travel (1,2,3,4,5) (negative to quit) > 5 Enter units to travel (negative for backwards) > -2 Location: [1 3 2 5 8] = Black Enter dimension to travel (1,2,3,4,5) (negative to quit) > 5 Enter units to travel (negative for backwards) > 2 Location: [1 3 2 5 0] = White Enter dimension to travel (1,2,3,4,5) (negative to quit) > 5 Enter units to travel (negative for backwards) > -1 Location: [1 3 2 5 9] = Black Enter dimension to travel (1,2,3,4,5) (negative to quit) > 5 Enter units to travel (negative for backwards) > 1 Location: [1 3 2 5 0] = White Enter dimension to travel (1,2,3,4,5) (negative to quit) > 2 Enter units to travel (negative for backwards) > -3 Location: [1 0 2 5 0] = Black Enter dimension to travel (1,2,3,4,5) (negative to quit) > 3 Enter units to travel (negative for backwards) > -2 Location: [1 0 0 5 0] = Black Enter dimension to travel (1,2,3,4,5) (negative to quit) > 3 Enter units to travel (negative for backwards) > 5 Location: [1 0 5 5 0] = Lime Enter dimension to travel (1,2,3,4,5) (negative to quit) > 3 Enter units to travel (negative for backwards) > 5 Location: [1 0 0 5 0] = White Enter dimension to travel (1,2,3,4,5) (negative to quit) > 4 Enter units to travel (negative for backwards) > 5 Location: [1 0 0 0 0] = White Enter dimension to travel (1,2,3,4,5) (negative to quit) > -1 The scientist gives up on the quest for understanding. 

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago