Questions tagged [acm-java-libraries]

The ACM Java Libraries were produced by the ACM's Java Task Force with the aim of simplifying the teaching of Java to first-year undergraduate students.

The ACM Java Task Force Libraries and API were produced by the Association of Computing Machinery's Java Task Force with the aim of simplifying the teaching of Java to first-year undergraduate students.

As observed here and here, it may be necessary to compile under Java 1.5 to avoid regressions seen with later versions of Java.

113 questions
0
votes
1 answer

Run java script utilizing acm.program package from terminal

I am trying to run the following script - source of code here- on my terminal: import acm.program.*; public class Add2 extends Program { public void run() { println("This program adds two numbers."); int n1 = readInt("Enter n1: "); …
Yuna Luzi
  • 318
  • 2
  • 9
0
votes
2 answers

how to fill every second rectangle / Java / acm / chessboard

I'm currently developing a simple chessboard with Java ACM and I want to fill every second rectangle with a color but I don't know how to. for (i = 0; i < 400; i += 50) { for (j = 0; j < 400; j += 50) { GRect rect = new…
geforth
  • 9
  • 1
0
votes
1 answer

java mouse question ACM packages program and graphics

I have 2 classes, A and B. A is a subclass of Program (i.e. acm.program.*) and B is a subclass of GCanvas(i.e. acm.graphics.*). In Class A I have an init method which initiates and adds class B. In Class B I have 2 things I want to achieve: I…
Steven
  • 29
  • 1
  • 1
  • 6
0
votes
0 answers

Why is my JPanel taking half of the screen and how can i fix this?

I am having an issue where it seem like my JPanel is taking half of my screen no matter what, even though it doesn't need to. I am using the acm package to make a graphical simulation, with sliders to adjust the parameters of a simulation import…
AlexCh
  • 1
  • 1
0
votes
1 answer

Why is everything after the space not printed?

I created a simple program using the acm library that takes a user inputted string and prints it out in morse. This is the program: import acm.program.*; public class morse extends Program{ public void run(){ String[] alphabet =…
GravityWell
  • 92
  • 1
  • 8
0
votes
1 answer

JAVA acm getBound.intersects doesn't work properly?

Hey so i have to make this game, basically a ball (bug) needs to change directions once it hits other objects, (rectangles and objects) Im using getBounds.intersects to see if it hits the objects or not, but it doesn't work if the ball goes from…
0
votes
2 answers

Getting started with Java acm

Just getting started here. I've had programming classes before, but am new to Java and have no substantial experience. This program is from Mehran Sahami's Stanford lecture posted to Youtube. https://www.youtube.com/watch?v=YpZCKVG4s5k&t=1996s The…
Saint Razz
  • 53
  • 1
  • 7
0
votes
4 answers

How can I expand things from a superclass? (Java)

I want to expand the method setValueAt(int row, int col, int value) from the superclass NumberBoard in my subclass Sudoku. In Sudoku the value is empty or 1 to 9, but in the superclass NumberBoard the value may be empty or >= 0. How can I change it…
0
votes
1 answer

Java Run another class with a JButton

public class SocialNetwork extends Program implements Constants { Canvas canvas = new Canvas(); public void init() { breakoutButton = new JButton("Play Breakout Game"); breakoutButton.setForeground(Color.WHITE); …
user7091463
  • 137
  • 3
  • 5
  • 12
0
votes
1 answer

repeat "readInt" till the input is wrong

I want to solve a small problem, but for me it's a big one. "This program should start by asking the user for N; if N is outside of the desired range, the user should be asked again." ACM library: int N = readInt("Enter N (0 <= N <= 10): "); while…
0
votes
2 answers

How does my program run when I don't have a main method

I am studying java course in my college and we are using a library called acm. But when we write a code we don't create a main method. "public void run(){}" acts as a main method. Explain please. For an example here's a program that I…
Coder
  • 5
  • 4
0
votes
2 answers

ACM Library simple example not working with jdk 1.7.0_79

Hi All java Experts! When I tried a little example of acm library import acm.program.*; class prog extends ConsoleProgram { public void run() { int number = readInt("?"); println("You entered: " number); } …
user3051677
  • 147
  • 14
0
votes
1 answer

Java Glitchy Collision Detection with ACM Graphics

I'm quite new to Java and I am using the ACM library for graphics. What I'm trying to do with this code is to: Introduce two balls, one on the left side and one in the middle. Both of them are in the middle, y coordinate-wise. Make the first ball…
Glycerius
  • 185
  • 2
  • 7
0
votes
2 answers

save to and load from not working in java

for the life of me I can't figure out what is wrong with these codes .. the save to keep overwrite itself and the load from doesn't load the already existing data .. I have searched for this code but it seems like people use different codes ..…
jill
  • 23
  • 6
0
votes
2 answers

Exception in thread "main" java.lang.StringIndexOutOfBoundsException

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 7 at java.lang.String.charAt(Unknown Source) at DNAmatch.findFirstMatchingPosition(DNAmatch.java:100) at DNAmatch.run(DNAmatch.java:82) …
Sakis
  • 31
  • 12