Software Engineering Quiz 3 & 4

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/5

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

6 Terms

1
New cards

Library to import for user input

import java.util.Scanner;

2
New cards

Code to get user input for name

Scanner scan = new Scanner(System.in)
System.out.println("Enter your name: ");

theName = scan.nextLine();

3
New cards

.next() vs .nextLine()

  • next reads until space

  • nextLine reads until \n

4
New cards

Important note about .next()

.next leaves \n in buffer

so…

System.out.print("Enter age: ");
int age = sc.nextInt();

System.out.print("Enter name: ");
String name = sc.nextLine();  // This may be skipped

5
New cards

Code to establish an abtract Piece class with an abtract move method

abtract public class ChessPiece{ 
// Stuff goes in here

abtract public void move();

}

6
New cards

Code to extend the ChessPiece class with a Queen class (Add constructor and move)

public class Queen extends ChessPiece {

	public Queen(int row, int col)
		super(row,col)

	@Override
	public void move() {
		// Stuff here
	}
}