Category Archives: Computer Science

Array Fun 3 [Resizing] Version 2

Version 1

ArrayFun3 –  Please call your class that , exactly. Yes, you will lose a point for not following this simple specification.

  • use meaningful variable names
  • use  camelCase for variable and method names
  • use  i  as the variable name for for-i loops . Remember – programming is generally done in teams so your code should be  as expressive as possible. Use conventions to convey meaning, not cause confusion.
  • do not use i  as the variable name in for-each  loops. Again, this would be misleading and imply you’re using a different type of loop.
  • do not import any external libraries . All solutions can be done by making use of variables and arrays and some basic math ; nothing more is needed.

 

int[]  removeZeroes(int [] nums)

Description: This method returns a version of nums  in which all occurrences of 0 , zero, are  removed

Method Call return value/output
noZeroes(  { 3 , 4, 0, 1} ) { 3, 4, 1}
noZeroes(  { 0, 5 , 0, 0, 9, 0, 1 , 11} ) { 5,9,1,11}

String[]  removeNulls(String[] strs)

Description: This method returns a version of strsin which all null  values are removed. Note: removeNullsv2

 


int[] digitsToArray(int n)

@precondition n > 9

Description: This method takes each digit in the integer n  and stores it in an array in reverse order, as shown below. First, make sure you understand the code here. , which btw, testers had to figure out , on the fly, in a previous AP A test.

digitstoarray


int[] removeLeadingZeroes(int[] nums)

@precondition nums.length >=2 

Description: This method returns an array in which all elements that meet the 2 criteria below are removed.

  • the element has a value of 0, zero
  • the element’s index is less than the index of the first element whose value is not zero.

 

remove_leading_zeros


 int[]  doubleUp( int  [] nums, int val)

@precondition nums.length >=2 

Description: This method returns a version of nums  –with all occurrences of val   duplicated.

Method Call return value/output
doubleUp(  { 3 , 4, 0, 1}  , 4  ) { 3, 4, 0, 1}
doubleUp(  { 1, 3 , 1, 5 , 3, 3} ,  3 )    {1 , 3,  , 1, 5 , 3, 3, 3, }

 

 

 

Similar problems on codingbat

Pre4

Unit 2 Extra Credit

In addition to the required Unit 2 Creative Task, if you want some extra credit, you can do the following assignment:

Research how groups work in CMU ( see the docs)

Write a program that

  • includes two functions
  • minimum of 5 objects
  • A group comprised of at least 3 objects
  • One of the functions must change the properties of all things in the group.

You can write this in one of empty creative a tasks.

CMU Unit 2, creative task – mousepress mousedown

For this creative task,

This is a 10 Point assignment:

To get 9 points:

  • minimum of 2 shapes
  • minimum of 2 functions
    • 1 must be a mouse function (mousePress, mouseMove, mouseRelease)
    • the other function can be any function at all
    • one of the functions must change a property (fill, width etc) of the shape

To get the 10th point,

Research how groups work in CMU ( see the docs),

  • Use a  group comprised of at least 3 objects
  • 1of the functions must change the properties of all things in the group.

Bs4 template

Copy and Paste the HTML file below into its own file

Updated Version:

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap 4.6 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
 <!-- jQuery --> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script> 

    <title>Hello, world!</title>
  </head>
  <body>
	  <div class="container">
		<h1>Hello, world!</h1>

  






	  </div> <!-- .container end-->
  </body>

    <!-- Bootstrap .bundle includes popper -->
	  
	  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
	  
	  
	  
</html>

 

 

Version 1:

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
 <!-- jQuery --> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script> 

    <title>Hello, world!</title>
  </head>
  <body>
    <h1>Hello, world!</h1>

    <!-- Optional JavaScript -->
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </body>
</html>


 

SUPA – Web 2022-23

Quarter 4 project

 

Prior iterations : https://mrmonline.org/supa-2020/ , https://mrmonline.org/web-design-programming-18-19/

 

Templates

Bootstrap

Vim 

SeatingChart Java OOP Project – 2D Arrays

Let’s write a program for something like PowerSchool that helps organize a seating chart for students.  There is a tester file at the page’s bottom.

First class : Student   , from https://mrmonline.org/student-class/

Class SeatingChart

This class mainly manages a 2-d  array of student objects. Note: an empty seat in the chart will be designated by a null  value.

private Student[][] chart ; // rows and columns for where kids are
private String rosterName; //name of this roster
private String teacherName; 
private int period ; //which period is this chart associated 
public static final int DEFAULT_ROWS = 10;
public static final int DEFAULT_COLS = 10;

Constructor(s)

  • public SeatingChart(int per, String teacher, String _rosterName)  Initializes parameters to respective arguments and creates a 2-d array  of null  objects with default dimensions DEFAULT_ROWS , DEFAULT_COLS
  • public SeatingChart(int per, String teacher, String _rosterName, Student[][] table)

Methods:

public String getTeacherName() // returns teacherName

public String getRosterrName() // returns  rosterName

public int getPeriod()  // returns period

public int countEmptySeats()  ; //returns the number of empty seats. As noted earlier, an empty seat is represented by a null  value in the 2-d array of student s

Student[][] getStudentChart()  @returns chart

public int[] indexOf(Student stu);  returns a 2 element array representing the row and column position of stu in chart ; [-1 , -1] should be returned if stu is not in chart

public boolean setSeat(int row, int col, Student stu) –  places Student Stu   at that row  and column .  This can only be done if there is no student in that location. If a student already inhabits that row and column then the method should return false  and not make any changes to chart .

public void swap(Student s1, Student s2)  // this swaps the locations of s1  and s2

public Student getStudent(int row, int col)  returns the student at the given row  and col ; or null  if the seat is empty

public void removeStudentAt(int row, int col)   sets value of object at row  and col  to null 

public boolean equals(SeatingChart other)  // returns true  if all aspects of other are equivalent to self.

public void colMajorForm()  . This prints out the student chart in column major form.   Examine the diagram below showing an example seating chart on the left and the printed output on the right.seating chart col major

public String toString();  //follow the conventions we have been using. When you print out the chart , let’s show “E!” t o indicate an empty seat; for seats with students, just display their name.SeatingChart to string v2

public Student oldest()  // returns the student object with the greatest age

Extra credit

public void randomize()  // this randomizes the chart. Please be prepared to meet with me to discuss your code. (You cannot use a library to do all the work, if such a library even exists)

 

SeatingChartTesterv2.java :

[pastacode lang=”cpp” manual=”import%20java.util.Arrays%3B%0A%0Apublic%20class%20SeatingChartTesterv4%0A%7B%0A%20%20%20%20public%20SeatingChartTesterv4()%0A%20%20%20%20%7B%0A%20%20%20%20p(%22v4%2C%20null%20constructor%20checks%22)%3B%0A%20%20%20%20Student%20amelia%20%3D%20new%20Student(%22Amelia%22%2C%2017)%3B%0A%20%20%20%20Student%20antonioooo%20%3D%20new%20Student(%22antonioooo%22%2C%2014)%3B%0A%0A%20%20%20%20SeatingChart%20period3%20%3D%20new%20SeatingChart(3%2C%20%22Mr.%20M%22%2C%20%22A%20Days%22)%3B%0A%0A%20%20%20%20%0A%20%20%20%20int%20correct%20%3D%200%3B%0A%20%20%20%20int%20wrong%20%20%3D%200%3B%0A%0A%20%20%20%20boolean%20didNotInit%20%3D%20false%3B%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20if(period3.getTeacherName()%20%3D%3D%20null)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22*non*%20default%20constructordid%20not%20initialize%20teacherName%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20didNotInit%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20if(period3.getRosterrName()%20%3D%3D%20null)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22*non*%20default%20constructor%20did%20not%20initialize%20rosterName%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20didNotInit%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20if(period3.getStudentChart()%20%3D%3D%20null)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22*non*%20default%20constructor%20did%20not%20initialize%20chart%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20didNotInit%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%0A%20%20%20%20%20if%20(%20didNotInit%20%3D%3D%20true)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20throw%20new%20Error(%22You%20must%20fix%20your%20constructor%20(non%20default)%20before%20doin%20anything%20else%20%5Cn%5Ct%20exiting%20tester%22)%3B%0A%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%7D%0A%20%20%20%20%20%2F%2F%20now%20let’s%20do%20the%20same%20for%20default%20%20constructor%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2F%2FSeatingChart(int%20per%2C%20String%20teacher%2C%20String%20_rosterName%0A%20%20%20%20%20SeatingChart%20dfault%20%3D%20new%20SeatingChart(%202%2C%20%22Mr.%20Lorensax%22%2C%20%22periods%202%20%22)%3B%0A%20%20%20%20%20%0A%20%20%20%20%20if(dfault.getRosterrName()%20%3D%3D%20null)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22%20default%20constructor%20did%20not%20initialize%20rosterName%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20didNotInit%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20if(dfault.getStudentChart()%20%3D%3D%20null)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22%20default%20constructor%20did%20not%20initialize%20chart%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20didNotInit%20%3D%20true%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%0A%20%20%20%20%20if%20(%20didNotInit%20%3D%3D%20true)%0A%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20throw%20new%20Error(%22You%20must%20fix%20your%20constructor%20(%20%20default)%20before%20doin%20anything%20else%20%5Cn%5Ct%20exiting%20tester%22)%3B%0A%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%7D%0A%20%20%20%20%20%2F%2Fend%20%20non%20default%20constct%20test%0A%20%20%20%20%20%0A%20%20%20%20%20%0A%20%20%20%20Student%5B%5D%5B%5D%20currentChart%20%3D%20dfault.getStudentChart()%3B%0A%20%20%20%20if(currentChart%5B0%5D.length%20%3D%3D%20SeatingChart.DEFAULT_COLS%20%26%26%20currentChart.length%20%3D%3D%20SeatingChart.DEFAULT_ROWS)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22*default%20constructor’s%202-d%20Array%20incorrect%20dimensions%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20boolean%20result%20%3D%20period3.setSeat(5%2C6%2C%20amelia%20)%3B%0A%0A%20%20%20%20if(result)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22setSeat()%20return%20value%20error%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20Student%5B%5D%5B%5D%20chartNow%20%3D%20period3.getStudentChart()%3B%0A%20%20%20%20if(chartNow%5B5%5D%5B6%5D%20%3D%3D%20amelia)%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%0A%20%20%20%20%20%20%20%20if(%20period3.getStudent(5%2C6)%20%3D%3D%20amelia)%0A%20%20%20%20%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%20%20%20%20else%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20p(%22Error%2C%20looks%20like%20getStudent()%20%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%7D%20%20%20%20%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22A)%20erorr%2C%20probably%20from%20setSeat()%20or%20getStudentChart()%20%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%0A%20%20%20%20int%5B%5D%20locaxn%20%3D%20period3.indexOf(amelia)%3B%0A%20%20%20%20if(locaxn%5B0%5D%3D%3D5%20%26%26%20locaxn%5B1%5D%20%3D%3D%206)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22B)%20setSeat()%20or%20indexOf()%20error%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20result%20%3Dperiod3.setSeat(5%2C6%2C%20antonioooo%20)%3B%0A%0A%20%20%20%20if(result%3D%3D%20false)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22C)%20setSeat()%20return%20value%20error%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20String%20st%20%3D%20period3.toString()%3B%0A%20%20%20%20%0A%20%20%20%2F%2F%20System.out.println(st)%20%3B%0A%0A%20%20%20%20if(st.indexOf(%22SeatingChart%22)%20%3D%3D%200)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20p(%22toString()%20error.%20ClassName%20should%20be%20first%20characters%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%7D%0A%0A%20%20%20%20if(st.contains(%22Mr.%20M%22))%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20p(%22toString()%20error.%20%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%7D%0A%20%20%20%0A%20%20%20%20if(st.contains(%22A%20Days%22))%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%7B%0A%20%20%20%20%20%20%20%20p(%22toString()%20error.%20%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%7D%0A%2F%2Fnew%20seating%20chart%0AStudent%20tim%20%3D%20new%20Student(%22tim%22)%3B%0AStudent%5B%5D%5B%5D%20%20someKids%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20new%20Student(%22giorgio%22)%2Cnull%2C%20%20tim%20%2C%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20new%20Student(%22michael%22)%2C%20new%20Student(%22joe%22%2C%2012)%20%2C%20null%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20null%2C%20new%20Student(%22Alex%22)%2C%20new%20Student(%22Eliam%22%2C%20999)%2C%20null%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20new%20Student(%22Jen%22)%2Cnull%2C%20%20new%20Student(%22antonio%22%2C%205)%2C%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3B%0A%0A%20%20%20%20SeatingChart%20period4%20%3D%20new%20%20SeatingChart(4%2C%20%22MR%20M%22%2C%20%22p4%22%2C%20someKids)%3B%0A%2F%2FSystem.out.println(%20period4%20)%3B%0A%2F%2Fmake%20sure%20that%20someKids%20was%20actually%20set%20to%20the%20chart%0A%20if(period4.getStudentChart()%20%3D%3D%20null)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20p(%22Non%20default%20constructor’s%20chart%20not%20initialized%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20else%0A%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20%0A%20%20%20%20%0AStudent%5B%5D%5B%5D%20p4Chart%20%3D%20period4.getStudentChart()%3B%0Aif(%20Arrays.equals(p4Chart%20%2C%20someKids))%0A%20%20%20%20correct%2B%2B%3B%0Aelse%0A%20%20%20%20%7B%0A%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20p(%22Error%20.%20Looks%20like%20you%20did%20not%20correctly%20instantiate%202-d%20array%20in%20constructor%20%22)%3B%0A%20%20%20%20%7D%0A%0A%0A%0A%0A%20%20%20%20boolean%20isCorrect%20%3D%20true%3B%0AStudent%20oldest%20%20%3D%20null%20%3B%0A%20%20%20%20try%7B%0A%20%20%20%20oldest%20%3D%20period4.oldest()%3B%0A%20%20%20%20%7D%0A%20%20%20%20catch(NullPointerException%20e)%7B%0A%20%20%20%20%20%20%20%20isCorrect%20%3D%20false%3B%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20p(%22Error%20%40%20oldest()%2C%20you%20cannot%20call%20.getAge()%20on%20a%20null%20object%22)%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%0Aif(isCorrect%20%26%26%20oldest%20!%3D%20null%20%26%26%20oldest.getAge()%20%3D%3D999)%0Acorrect%2B%2B%3B%0Aelse%0A%20%20%20%20%7B%0A%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20p(%22Error%20%40%20oldest()%22)%3B%0A%20%20%20%20%7D%0A%20%20%20%20locaxn%20%3D%20period4.indexOf(tim)%3B%0A%20%20%20%20%0A%0A%0A%0A%20%20%20%20if(locaxn%5B0%5D%3D%3D0%20%26%26%20locaxn%5B1%5D%20%3D%3D%202)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22A%20incorrect%20student.%20Could%20be%20constructor%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%0Aif%20(%20period4.getStudent(0%2C2)%20%3D%3D%20tim%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22B%20incorrect%20student.%20Could%20be%20constructor%2C%20getStudent()%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%2F%2F%2F%0A%0A%0Aint%20emptySeats%20%3D%20period4.countEmptySeats()%3B%0A%0A%0A%0Aif(emptySeats%20%3D%3D%205)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22countEmptySeats()%20error%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0AStudent%20vinnie%20%3D%20new%20Student(%22Vinnie%22%2C%2016)%3B%0AStudent%20yuya%20%3D%20new%20Student(%22Yuya%22%2C%2018)%3B%0AStudent%5B%5D%5B%5D%20%20p5Kids%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20yuya%2C%20vinnie%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3B%0A%0ASeatingChart%20period5%20%3D%20new%20%20SeatingChart(4%2C%20%22MR%20M%22%2C%20%22p4%22%2C%20p5Kids)%3B%0A%0Aint%5B%5D%20%20yuyaLocation_befo%20%3D%20period5.indexOf(yuya)%3B%0Aint%5B%5D%20%20vinniaLocation_befor%20%3D%20period5.indexOf(vinnie)%3B%0A%0A%0A%0Aperiod5.swap(vinnie%2Cyuya)%20%3B%0Aint%5B%5D%20%20yuyaLocation_now%20%3D%20period5.indexOf(yuya)%3B%0Aint%5B%5D%20%20vinniaLocation_now%20%3D%20period5.indexOf(vinnie)%3B%0A%0Aif(%20yuyaLocation_now%5B0%5D%20%3D%3D%20vinniaLocation_befor%5B0%5D%20%26%26%20%20yuyaLocation_now%5B1%5D%20%3D%3D%20vinniaLocation_befor%5B1%5D%20%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22Error%20Swap%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0Aif(%20vinniaLocation_now%5B0%5D%20%3D%3D%20yuyaLocation_befo%5B0%5D%20%26%26%20%20vinniaLocation_now%5B1%5D%20%3D%3D%20yuyaLocation_befo%5B1%5D%20%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22Error%20Swap%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%2F%2F%2F%2F%0A%2F%2F%0A%0A%0AStudent%20rany%20%3D%20new%20Student(%22rany%22%2C%2016)%3B%0AStudent%5B%5D%5B%5D%20%20p6Kids%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20rany%2C%20null%2Cnull%2Cnull%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20null%2C%20null%2Cnull%2Cnull%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%3B%0A%0ASeatingChart%20period6%20%3D%20new%20%20SeatingChart(4%2C%20%22MR%20M%22%2C%20%22p4%22%2C%20p6Kids%20)%3B%0Aperiod6.removeStudentAt(0%2C0)%3B%0Aif(%20period6.getStudent(0%2C0)%20%3D%3D%20null%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22Error%20%40%20removeStudentAt()%20%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0Aif(%20period5.equals(period6)%20%3D%3D%20false)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22A%20Error%20%40%20equals()%20%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0Aif(%20period5.equals(period5)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22B%20Error%20%40%20equals()%20%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0ASeatingChart%20period6Clone%20%3D%20new%20%20SeatingChart(4%2C%20%22MR%20M%22%2C%20%22p4%22%2C%20p6Kids%20)%3B%0A%0Aif(%20period6.equals(period6Clone)%20)%0A%20%20%20%20%20%20%20%20correct%2B%2B%3B%0A%20%20%20%20else%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20p(%22C%20Error%20%40%20equals()%20%22)%3B%0A%20%20%20%20%20%20%20%20wrong%2B%2B%3B%0A%20%20%20%20%20%20%20%20%7D%0A%0A%0A%0A%0Ap(%22———————————-%22)%3B%0Ap(%22Correct%20%3A%20%22%20%2B%20correct)%3B%0Ap(%22Wrong%20%3A%20%22%20%2B%20wrong)%3B%0A%0A%0A%20%20%20%20%7D%2F%2Fend%20of%20constructor%0A%0Avoid%20p(String%20x)%20%7B%20System.out.println(x)%3B%20%7D%0Avoid%20p(int%20x)%20%7B%20System.out.println(x)%3B%20%7D%0Avoid%20p(boolean%20x)%20%7B%20System.out.println(x)%3B%20%7D%0Avoid%20p(double%20x)%20%7B%20System.out.println(x)%3B%20%7D%0Avoid%20p2d(int%5B%5D%20x)%20%7B%20System.out.println(x%5B0%5D%20%2B%20%22%2C%20%20%22%20%2B%20x%5B1%5D)%3B%20%7D%0A%0A%7D%0A” message=”SeatingChartTester” highlight=”3″ provider=”manual”/]