Rubik’s Cube Simulator In this project, you will be creating

  

Rubik’s Cube Simulator

In this project, you will be creating a Rubik’s Cube simulator. 

Setup

Before beginning the lab you will need to do the following things:

1. Create a folder within your class folder and name it Rubik. All of your files for this project must be saved in this CIS36A/Rubik directory.

2. Download the following files into your CIS36A/Rubik directory:

o RubikRunner.java Download RubikRunner.java

o RubikCube.java Download RubikCube.java

o RubikFace.java Download RubikFace.java 

3. Always compile and run RubikRunner.java class. It will automatically compile the other supporting classes. 

Submission

Submit all of your final source files

Submit sample console runs for all of the parts below. 

Part 1 – Create a Cube

You will be given the main program class (RubikRunner). You will not need to change RubikRunner.

You will also be given the skeleton to the Rubik’s Cube class (RubikCube) and a placeholder class describing the face of a Rubik’s Cube (RubikFace).  You will not have to change RubikFace.

Your assignment is to:

1) Implement the RubikCube constructor.  The constructor takes no arguments and creates and populates an array of RubikFace objects.  Each RubikFace should have its own color (ex: full color name: “White”).

2) Implement the toString() method of RubikCube.  The output of the method should be the net of the cube, with the front face in the center, as shown below.

Sample Run

    W
B O G
   Y
   R

 

Colors:

W: White

O: Orange

B: Blue

Y: Yellow

R: Red

You must use the faces array in your toString method to receive full credit.

Part 2 – Rotate the entire Cube

In this part, you will write code to rotate the cube.  You will need to implement a loop asking the user what direction to rotate in RubikRunner, and implement left(), right(), up() and down() methods in RubikCube that will rotate the cube in the given direction.  For example, if the cube looks like:

    W
B O G
   Y
   R

and you rotated left, the cube would now look like:

     W
O G R
    Y
    B

Your assignment is to:

1) RubikCube.java – Implement the 4 commands as void methods – left(), right(), up(), down()

2) RubikRunner.java – add a command loop that asks the user for which direction to turn the cube, including the option to exit the program.  After each turn is executed, print out the cube.

3) RubikFace.java – still nothing to do on this one, yet.

Sample Run

    W
B O G
   Y
  R
 

What direction? q to quit
What direction [right, left, up, down]: left
    W
O G R
   Y
   B
 

What direction? q to quit
What direction [right, left, up, down]: right
   W
B O G
   Y
   R
 

What direction? q to quit
What direction [right, left, up, down]: up
   O
B Y G
   R
   W
 

What direction? q to quit

 What direction [right, left, up, down]: down

   W
B O G
   Y
   R
 

What direction? q to quit
What direction [right, left, up, down]: q

 Part 3 – Nine-facet version of each face

In this part, you will be working mostly with the RubikFace class.  

Your assignment is to:

1) RubikFace – Add a 3×3 array to RubikFace that will hold the colors for each of the 9 facets on the face.  For now, set each of the facets to be the same color as the face.  You will also have to modify the toString method to return a 3×3 grid of colors.  If, for example, the color of the face was Red, your toString method should return:

 R R R
R R R
R R R

2) Update any methods in RubikRunner or RubikCube that require updating as a result of this change.

Starting with this activity, you need to comment on your code. 

Sample Run

       W W W
      W W W
      W W W
B B B O O O G G G
B B B O O O G G G
B B B O O O G G G
      Y Y Y
      Y Y Y
      Y Y Y
      R R R
      R R R
      R R R
 

What direction? q to quit
What direction [right, left, up, down]: left
      W W W
      W W W
      W W W
O O O G G G R R R
O O O G G G R R R
O O O G G G R R R
      Y Y Y
      Y Y Y
      Y Y Y
      B B B
      B B B
      B B B
 

What direction? q to quit
What direction [right, left, up, down]: up
      G G G
      G G G
      G G G
O O O Y Y Y R R R
O O O Y Y Y R R R
O O O Y Y Y R R R
      B B B
      B B B
      B B B
      W W W
      W W W
      W W W
 

What direction? q to quit
What direction [right, left, up, down]: down

      W W W
      W W W
      W W W
O O O G G G R R R
O O O G G G R R R
O O O G G G R R R
      Y Y Y
      Y Y Y
      Y Y Y
      B B B
      B B B
      B B B
 

What direction? q to quit
What direction [right, left, up, down]: right
      W W W
      W W W
      W W W
B B B O O O G G G
B B B O O O G G G
B B B O O O G G G
      Y Y Y
      Y Y Y
      Y Y Y
      R R R
      R R R
      R R R

 Part 4 – Shuffled Cube

In this part, you will write the first step of code to rotate one face of the Rubik’s Cube.  When you rotate an actual Rubik’s Cube, the front rows on the sides move with the face you’re rotating – we’re not doing that.  yet …

You will be working mostly with RubikFace in this exercise. 

Your assignment is to:

1) Modify the constructor for RubikFace. RubikFace will need to have randomly generated colors in each of the cells, except the center cell which will remain the color that is passed through to the constructor.

2) Modify RubikRunner to accept 2 new commands: cw (for clockwise) and ccw (for counter clockwise).  Each of those commands will call the corresponding new RubikCube methods that you will create.  Those new RubikCube methods (ccw() and cw()) will call the corresponding new methods in RubikFace. Note that the rotated face is always the front face (face 2).

The RubikFace methods will rotate the face 90 degrees in the indicated direction.

Note: if you did not get your faces to print out correctly in Part 3, substitute printing just the front face in your toString for RubikCube.

Sample Run

        G Y Y
      G W W
      Y O B
Y W R G Y R B W O
B B Y R O G G G G
R W B R B W G B R
      B O R
      O Y Y
      Y O R
      W W R
      B R B
      Y B O
 

What direction? q to quit
What direction [right, left, up, down]: cw
      G Y Y
      G W W
      Y O B
Y W R R R G B W O
B B Y B O Y G G G
R W B W G R G B R
      B O R
      O Y Y
      Y O R
      W W R
      B R B
      Y B O
 

What direction? q to quit
What direction [right, left, up, down]: cw  
      G Y Y
      G W W
      Y O B
Y W R W B R B W O
B B Y G O R G G G
R W B R Y G G B R
      B O R
      O Y Y
      Y O R
      W W R
      B R B
      Y B O
 

What direction? q to quit
What direction [right, left, up, down]: ccw
      G Y Y
      G W W
      Y O B
Y W R R R G B W O
B B Y B O Y G G G
R W B W G R G B R
      B O R
      O Y Y
      Y O R
      W W R
      B R B
      Y B O

Part 5

Finally – your simulator will be complete! This assignment will complete the ability to fully rotate your cube.

The basic methods you need for this are in place – the cw() and ccw() in RubikCube. You will need to modify cw() and ccw() in RubikCube to rotate the matching columns or rows of the top, left, right and bottom faces when the front face is rotated. You may need to create other methods in either RubikCube or RubikFace to support your efforts.

Sample Run

        Y G G
      G W B
      O B R
G Y Y B W W B W R
G B W R O R W G G
G B B G R O W G B
      G W W
      G Y B
      B G B
      O B O
      B R O
      W R G
 

What direction? q to quit
What direction [right, left, up, down]: cw
      Y G G
      G W B
      B W Y
G Y G G R B O W R
G B W R O W B G G
G B W O R W R G B
      W W B
      G Y B
      B G B
      O B O
      B R O
      W R G
 

What direction? q to quit
What direction [right, left, up, down]: ccw
      Y G G
      G W B
      O B R
G Y Y B W W B W R
G B W R O R W G G
G B B G R O W G B
      G W W
      G Y B
      B G B
      O B O
      B R O
      W R G

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

Some believe that the misbehavior at Enron was attributable to

Some believe that the misbehavior at Enron was attributable to “bad apples”—people who would have acted unethically no matter where they worked. Others believe that the misbehavior at Enron stemmed from contextual factors (e.g., company culture, incentives, lax regulations, etc.) that would have led many people to act unethically if

Advances in Cognition.

Description 1) List and describe at least 5 specific activities or skills that kids learn to do with “automaticity” in middle childhood. (Ex. Learning the time’s tables in math). 2) Why is developing automaticity important? What did you do with automaticity today? 3) Try to come up with a few

NGR 6503 MDC Ethical Decision Making in Psychiatry Case Nursing Assignment Help

Ethical Decision making in Psychiatry. Using the following readings please discuss the following prompts: Digital Psychiatry: Risks and Opportunities for Public Health and Well-Being Artificial Intelligence for Mental Health and Mental Illnesses: An Overview 3 Ethical Issues in Online Psychotherapy: A Narrative Review Questions: What is the risk of using

Develop a 3-4 page (more is fine) mock chapter one

  Develop a 3-4 page (more is fine) mock chapter one to include the following expectations: Overview (1-2 well developed paragraphs) Background and problem statement (1-2 well developed paragraphs) Purpose of the study (1 well developed paragraph) Significance of the study (1 well developed paragraph) Research Questions (numbered list) Limitations

The following are examples of problems in your professional practice

   The following are examples of problems in your professional practice that may benefit from educational research. Lack of parental involvement, challenges in effective classroom management and the high burn out rate of teachers Briefly describe your field of professional practice, Family child care, and share two or three of

· Ashcraft v. Tennessee, 322 U.S. 143 (1944) Personal Evaluation,

   · Ashcraft v. Tennessee, 322 U.S. 143 (1944) Personal      Evaluation,      by answering the following: What are the overall conclusions of the case? What are the overall implications from the case as it relates to the subject-matter therein?  Do you agree with the conclusion of the Court? Why or why

Instructions For this scholarly activity, develop a supporting human resource

Instructions For this scholarly activity, develop a supporting human resource (HR) plan for an organizational strategy by completing the following tasks: Research a company that has undergone (or attempted to undergo) a shift in organization or culture within the past five years. This shift must have been a result of

This is a graded discussion forum. Your first message should

  This is a graded discussion forum. Your first message should be posted by Wednesday. At least 3 comments are required. The best practice is to post at the beginning, middle, and end of the week. Required: The Week 1 Discussion consists of three separate questions. You will answer one

our priority is that students are provided with strong educational

 our priority is that students are provided with strong educational programs and courses that allow them to be servant-leaders in their disciplines and communities, linking research with practice and knowledge with ethical decision-making. This assignment is a written assignment where students will demonstrate how this course research has connected and put

Comparing Vendors Part I As a healthcare leader, it is

  Comparing Vendors Part I As a healthcare leader, it is important to realize that you will be tasked to evaluate and select an EHR as part of an upgrade or a new implementation. In either scenario, it is important to be equipped with all the necessary information for a

Topic: Sexual abuse of female workers in their workplaces has

Topic: Sexual abuse of female workers in their workplaces has been a severe societal problem globally. Not much progress has been realized besides the many efforts to deal with the problem from all corners. This paper aims to evaluate some of the potential solutions that can be implemented in the

Human Resource Management: Briefing paper

Write a briefing paper answering the two questions below. The first question is worth 6 marks, the second question is worth 4 marks, for a total of 10 marks for the assignment. About 1000 well-chosen words not counting references may be sufficient to answer the questions. Question 1. Your company

Technology for Patient Safety in Saudi Arabia Paper Nursing Assignment Help

You are the manager of a busy hospital unit.  Your unit has been tasked with selecting and implementing upgraded technology on your hospital unit.  As the unit manger, address the following in your selection of technology and implementation plan: Examine the features of the new technology that are important in

This assignment is due on FRIDAY (10PM Chicago Time) This

   This assignment is due on  FRIDAY (10PM Chicago Time) This is a PowerPoint assignment  Please use the example of the PowerPoint uploaded to complete the PowerPoint I created I have started working on thIS POWERPOINT  but need help to complete it TOPIC; Enhancing teamwork across care provider levels:  The manager

Describe the four stages of delay behavior. What are the

Describe the four stages of delay behavior. What are the likely causes of delay?  A delay is the time frame from which a symptom is recognized to the time that a person that decides to get treated (p. 167). There are four different types of delays: appraisal, illness, behavioral, and