Java Array Programming Projects Student Labs

[ Home] [ Site Map ]


Array Manipulation

Moderate Difficulty

Fun Array Project In this project, you will perform various operations on an array of ints and and an array of doubles (Source code for the project)
String Array Project
  • the StringArr class as follows
    • The Constructors
      • Default Construct should initialize the sArr instance variable to
      3 different strings (of your choosing)
      • Write a constructor with a single parameter, an array of strings, and initialize sArr to the parameter
    • Methods
        Description: This method prints all elements in col. Precondition: Assume that col is always a valid column in arr. +1 extra credit: research try{}cathc() statements to catch any ArrayIndexOutOfBoundsException and handle situtions where col is not always valid. following:
      • a default constructor that initializes the instance variables.
      • the array should be initialized to have empty Strings
      • Instance Variables
        • Student[][] theChart
        • String teacher
      • Constructors
        • public SeatingChart()
          • initializes all variables
        • public SeatingChart(Student[][] seats, String teacherName)
          • that initializes theChart and teacher to the parameter
        • Mutator methods:
        • public void add(Student s, int r,int c) //adds Student s to the seating chart at row r and column c
        • public void clearAllSeats(); //this should set all elements in the chart to null
        • public void swap(int row1,int col1, int row2, int col2) Swaps Student at row1,col1 with Student at row2, col2
        • public boolean swap(Student s1,Student s2) ;;//Swaps s1 with s2. Returns false if either element is nonexistent in theChart.
        • Accessor methods:
        • public boolean contains(Student s); //returns true if Student is in the the chart.
        • public int[] getCell(Student s);//returns a two element arrow indicating the row and column ofstudentName. If str is not in array return an empty array.
        • public int getRow(Student s) ;//returns the row number of Student s; returns -1 if Student is not in array
        • public int getCol(Student s)//returns the column number of Student s; returns -1 if Str is not in array
        • public Student get(int row ,int col); //returns the Student at row, col.
        • public String toString() //you know what you need to do
        • public boolean equals(SeatingChart other)// returns true if each row, column has the exact same student and if teacher is the same for both other and for this
        • * public int compareTo(SeatingChart other) //returns the difference between this and other in terms of how many seats are occupied.
        • ** public SeatingChart alphabetize() //returns a version of the SeatingChart with the students arranged in alphabetical order.
  • Site Map | Resources | Online Math Games | Fraction Games Online | TOS | Programming Homework Help Sitemap